# FailureHandling.OPTIONAL custom message print issue using KeywordUtil

**URL:** <https://forum.katalon.com/t/failurehandling-optional-custom-message-print-issue-using-keywordutil/6795>\
**Category:** Miscellaneous\
**Created:** [October 12, 2017, 3:51am UTC](https://forum.katalon.com/t/failurehandling-optional-custom-message-print-issue-using-keywordutil/6795 "2017-10-12T03:51:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Praveen\_Kumar](https://avatars.discourse-cdn.com/v4/letter/p/ce73a5/32.png) [@Praveen\_Kumar](https://forum.katalon.com/u/Praveen_Kumar)\
**Post date:** [October 12, 2017, 3:51am UTC](https://forum.katalon.com/t/failurehandling-optional-custom-message-print-issue-using-keywordutil/6795/1 "2017-10-12T03:51:15Z")

</div>

As per the forum solution, if a statement including FailureHandling.OPTIONAL fails to run then using KeywordUtil.markErrorAndStop("i am failed ") custom message should print, but when the statement is passed KeywordUtil.markErrorAndStop("i am failed ") this statement should not run. So my issue is this statement KeywordUtil.markErrorAndStop("i am failed ") is executing in both the cases. for better understanding I have attached the code.

WebUI.setText(findTestObject(‘Page\_Facebook log in or sign up/input\_email’), ‘ayx@gmail.com’, FailureHandling.OPTIONAL)

if(FailureHandling.OPTIONAL == **what should come here**  **?** )  
{  
KeywordUtil.markErrorAndStop("i am failed ")  
}  
else  
{  
this statement should run  
}  
in this case only else part should run but if part is running. PLEASE PROVIDE Solution  
i know Failurehandling is enum, but how should i compare and against which in if statement: for ex: if(FailureHandling.OPTIONAL == true ) something like this possible. ~~~~~~~~

---

<div class="post-metadata">

**Author:** ![Praveen\_Kumar](https://avatars.discourse-cdn.com/v4/letter/p/ce73a5/32.png) [@Praveen\_Kumar](https://forum.katalon.com/u/Praveen_Kumar)\
**Post date:** [October 25, 2017, 8:16pm UTC](https://forum.katalon.com/t/failurehandling-optional-custom-message-print-issue-using-keywordutil/6795/2 "2017-10-25T20:16:25Z")

</div>

got the solution

if(WebUI.setText(findTestObject(‘Page\_Facebook log in or sign up/input\_email’), ‘ayx@gmail.com’, FailureHandling.OPTIONAL))  
{  
KeywordUtils.logInfo(“enter your string”)

or  
KeywordLogger log = new KeywordLogger  
log.loginfo(“enter your string”)  
}
