◷ Reading Time: 2 minutes
Exceptions are the errors that can occur during the execution of a project, disrupting the flow. This can happen due to different reasons and the exception message provides a detailed description of the cause.
Therefore, it is a good practice to catch the exceptions before it crashes the flow. For example, when an exception occurs, you can show the exception message (what caused the error) and how to fix it, instead of stopping the whole flow without any explanation.
1. Assigning to a transition: when there is one node to catch exceptions
2. Using a Try node: when there are multiple nodes to catch exceptions
Assigning to a transition
If a flow contains a database connection, there can be exceptions due to multiple reasons.
- The exception handling properties should be set to a transition that comes out of the node. In this example, it is the transition that connects the Database node and the Notification node.
- The error is assigned to a variable named error.
- Type: System.Exception
- Exception: error = $context.Exception.Message|asString()
Using a Try node
Follow this link to see how to use the Try node.
Downloadable sample project (Exception_Handling.zip) using the attachment at the end of the page.