Exception Handling

◷ Reading Time: 3 minutes

Introduction

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.

In FlexRule Designer, you can assign exceptions using a transition or Try node.

  1. Assigning to a transition
  2. Using a Try node

Assign to a Transition

When there is one node to catch exceptions, you can use a transition to catch the exception.

Let’s see an example of a database node in a flow.

  • If you select the transition’s Type property, you will get a list of Exception types to select from. Use Any, if you want to catch any exception that occurs, and click OK.
  • The above step only catches the exception. If you want to show an error notification, use a notification node.
  • Then add the notification message.
    Here we have added an Error notification, {$context.Exception.InnerException.Message}.
    It prints the exception message dynamically ( Use { } to print values dynamically).
  • Under the Notifications window, you can see the notification.

Use a Try Node

When there are multiple nodes to catch exceptions, you can put all the nodes inside a Try node.

After that, assign the exceptions to a transition in the same way you did in the above method.

Follow this link to see how to use the Try node.

Once you capture and handled the exceptions, you need to reset the exception before capturing another exception.
You can reset the exception by using the following expression as follows:

$context.Exception=null

Download Project

Downloadable sample project using the attachment at the end of the page.

Updated on October 30, 2023

Article Attachments

Was this article helpful?

Related Articles