0 / 0
Throwing an Exception class object (Java Integration stage)

Throwing an Exception class object (Java Integration stage)

You can use the Exception (java.lang.Exception) class or its subclass object from your Processor implementation to stop a job.

The following example shows Java™ code that does a basic calculation to get a price. If the value set to count is zero, the Java code throws the java.lang.ArithmeticException exception and logs the message: Divide by zero.

public void process() throws Exception
{
   int count = 0;
   int total = 1000;
   …
   int price = total / count;
}

The Java code can also construct an ArithmeticException object with a message that you specify and throw it to terminate a job.

public void process() throws Exception
{
   …
   if (result < 0)
   {
      throw new ArithmeticException("An exception occurred. result=" + result);
   }
}
Generative AI search and answer
These answers are generated by a large language model in watsonx.ai based on content from the product documentation. Learn more