# Can I use the FailureHandling option by itself without attaching it an event

**URL:** <https://forum.katalon.com/t/can-i-use-the-failurehandling-option-by-itself-without-attaching-it-an-event/40081>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [February 19, 2020, 3:56pm UTC](https://forum.katalon.com/t/can-i-use-the-failurehandling-option-by-itself-without-attaching-it-an-event/40081 "2020-02-19T15:56:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mridula.palivela](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@mridula.palivela](https://forum.katalon.com/u/mridula.palivela)\
**Post date:** [February 19, 2020, 3:56pm UTC](https://forum.katalon.com/t/can-i-use-the-failurehandling-option-by-itself-without-attaching-it-an-event/40081/1 "2020-02-19T15:56:56Z")

</div>

I want to fail the testcase for the following condition. I am able to run it, but the testcase is not failing right away. The test goes on to the next step. Please help with scenario so I can fail the testcase and the rest of the code does not run. TIA.

WebDriver driver = DriverFactory.getWebDriver()  
String ErrorMsg = driver.findElement(By.className(‘text-danger’)).text  
if (ErrorMsg == “”) {  
//testcase passed  
}  
else {  
//testcase failed  
FailureHandling.STOP\_ON\_FAILURE   
}

---

<div class="post-metadata">

**Author:** ![Timo\_Kuisma1](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/timo_kuisma1/32/16103_2.png) [@Timo\_Kuisma1](https://forum.katalon.com/u/Timo_Kuisma1)\
**Post date:** [February 19, 2020, 4:16pm UTC](https://forum.katalon.com/t/can-i-use-the-failurehandling-option-by-itself-without-attaching-it-an-event/40081/2 "2020-02-19T16:16:38Z")

</div>

hi,

check this chain

> [@Exception Handling for Custom Keywords](http://forum.katalon.com/t/exception-handling-for-custom-keywords/11742):
>
> Hi, I have created a custom keyword where, if the validation fails, I throw an exception. I am calling that Custom Keyword in my Test Case that is surrounded in a Try…Catch block. The Exception thrown in the Custom Keyword is not caught in the Test Case’s catch block. Could not post the original script but, below is a sample with the same control flow public class CheckException { @Keyword def chkEx(){ boolean check = true if (check == false){ throw new Exception(“Boolean is fasle”) } …

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [February 19, 2020, 4:44pm UTC](https://forum.katalon.com/t/can-i-use-the-failurehandling-option-by-itself-without-attaching-it-an-event/40081/3 "2020-02-19T16:44:34Z")

</div>

Use this:

> [@Tip: FORCESTOP](http://forum.katalon.com/t/tip-forcestop/11625):
>
> When developing lengthy Test Cases, it’s useful to be able to stop execution to examine the state of the browser. True, you could use the debugger, but many times it’s overkill and I don’t actually want to examine the test code. For me, this little method does exactly what I want – it kills the test at the exact point I need and allows me to do something in the browser: import com.kms.katalon.core.exception.StepErrorException as StepErrorException ... public class mytools { static void FO…

[https://docs.katalon.com/katalon-studio/docs/force-stop-execution.html](https://docs.katalon.com/katalon-studio/docs/force-stop-execution.html)

---

<div class="post-metadata">

**Author:** ![mridula.palivela](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@mridula.palivela](https://forum.katalon.com/u/mridula.palivela)\
**Post date:** [February 19, 2020, 4:54pm UTC](https://forum.katalon.com/t/can-i-use-the-failurehandling-option-by-itself-without-attaching-it-an-event/40081/4 "2020-02-19T16:54:09Z")

</div>

Thanks @Timo_Kuisma1 and @Russ_Thomas

Used StepErrorException and it worked!
