Throw Exception
The Throw Exception EIP throws exceptions during message processing, offering greater control over the integration flow. With it, you can interrupt execution in specific scenarios, handle failures in a customized way, and ensure the expected behavior of processes.
When an exception is thrown with Throw Exception, the integration flow is immediately interrupted, and the following steps are not executed until the exception is handled or caught.
All exceptions generated by this component are logged in the Analytics logs, allowing the user to easily monitor errors and failures that occur during flow execution.
Configuring the Throw Exception EIP in the Diagram
To configure a Throw Exception in an integration on the Diagram tab, follow these steps:
-
Click +Add Step on the canvas.
-
Select the EIPs tab.
-
Select the Throw Exception EIP. You can use the search tool to locate it.
-
Fill in the following fields:
-
Message: custom message that will be associated with the exception.
-
Exception Type: specific type of exception to be thrown.
Check frequently used exceptions:
Exception Type Description java.lang.IllegalArgumentException
Invalid parameter
java.lang.NullPointerException
Unexpected null value
java.lang.RuntimeException
Generic runtime exception
java.io.IOException
IO issues, such as file or network failure
javax.validation.ValidationException
Data validation failure
java.lang.UnsupportedOperationException
Unsupported operation
-
Example
Below is a configuration example of the Throw Exception EIP:
- from:
uri: rest:get:/demo
steps:
- log:
message: "Starting the flow. An exception will be thrown now."
- throwException:
message: Exception intentionally thrown by the EIP throw-exception
exceptionType: java.lang.IllegalArgumentException
-
The flow is triggered by a GET request.
-
The first step in the flow logs the following message: "Starting the flow. An exception will be thrown now." This serves as a monitoring point to indicate that the flow has started and an exception will be thrown next.
-
The
throw-exception
EIP is executed, and an exception of typeIllegalArgumentException
is thrown with the message: "Exception intentionally thrown by the throw-exception EIP". -
In practice, the client will receive an HTTP error (most likely 500 Internal Server Error) with the exception message, depending on your runtime configuration.
Share your suggestions with us!
Click here and then [+ Submit idea]