DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Munit: Parameterized Test Suite
  • Is It Okay To Stop Running Your Tests After the First Failure?
  • Projections/DTOs in Spring Data R2DBC
  • Event-Driven Order Processing Program

Trending

  • DZone's Article Submission Guidelines
  • Medallion Architecture: Why You Need It and How To Implement It With ClickHouse
  • Event-Driven Architectures: Designing Scalable and Resilient Cloud Solutions
  • Docker Base Images Demystified: A Practical Guide
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Testing, Tools, and Frameworks
  4. Error Handling Inside Kumologica Subflow

Error Handling Inside Kumologica Subflow

The article demonstrates the general error handling and skip-on error feature inside the Kumologica subflow.

By 
Pranav K user avatar
Pranav K
DZone Core CORE ·
Mar. 27, 23 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
2.9K Views

Join the DZone community and get the full member experience.

Join For Free

What Is a Subflow?

A subflow in Kumologica is a defined section of a flow that is created using a Subflow In and Subflow Out node. Its purpose is to improve the reusability of code and enhance the readability of the overall flow. The Subflow node can be used to call the subflow from any point in the flow.

Once a Subflow In node is added to the canvas, its name will appear in the dropdown list of the Subflow node. Each subflow execution operates within its own context and does not modify the payload, variables, or message properties.  

Error Handling Approaches

 When it comes to subflows, there are two ways to handle errors. The first approach involves catching the mistake, handling it, and then abruptly stopping any further processing. 

Stop on Error


Alternatively, the second approach is to catch the error and skip to the next processing block without stopping the flow. The second approach is mostly used when you are using the subflow inside a for loop for iteration. Whenever an error occurs inside the loop the catch node instead of wiring to an EvenListener End node will be wired to the For-Loop end node. By doing this the iteration is automatically skipped to the next iteration without doing any other processing associated with the for-loop processing block. Eg: In the below image Node 3 is skipped when thrown at Node 2. 

Skip on error

Implementation

Pre-requisite

1. Node.JS installation (node version: 16.14.0, npm version:  8.3.1)

1. Install the latest Kumologica designer  (3.1.0).

In this article, I will implement a simple Kumologica flow demonstrating both error-handling approaches. Following is the flow which I will be using for this demonstration.

Main flow


Steps

We will first build a subflow that is invoked from the main flow.

Sub flow


1. Click on the Navigator view in the designer and create a new flow by providing a name samplesubflow.

2. Drag and drop Subflow In and Subflow Out nodes from the pallet to the designer.

3. Add an HTTP Req node to the canvas and wire to the Subflow In node. 

4. Wire the HTTP Req node output to Subflow out node.

Provide the configuration for the HTTP Req node as given below.

Plain Text
 
Method : GET
URL : http://httpbin.org/wrongip
Return : a UTF-8 string


5. Now ensure that the main flow (Main flow image above) subflow invoke node is having the Subflow selected.

6.  Add a test case flow as given below to execute the flow to see if an error is generated. The test case flow will have an HTTP TestCase node wired directly to the TestCaseEnd node.

Test Case flow

Testing:

On running the test case from the test case runner option you could see the 404 error response as the HTTP endpoint we provided was incorrect.

Error Response


Stop on Error

1. Now let's capture the error thrown by the HTTP Req node. For this, we will configure a catch node as given below.Configuring Catch node

In the above screen, you can see that the HTTP req node is selected for catching all the errors generated by that node. 

2. Wire the Catch node to the Event Listener End node for sending the error response back to the client.

Configuring EventListener End node


Testing:

On running the test case we can see that error is handled and the custom response is returned by the flow. The flow is abruptly stopped

Handled errors and stopped


Skip on error

1. Now we try implementing skip-on an error by removing the Evenlistener End from the earlier built flow. 

2. Once the Evenlistner End node is removed, we will wire the catch node directly to the Subflow Out node.

Catch node wired directly


Testing:

On running the test case we can see that error is handled and skipped which ultimately completes the flow successfully.

Handled errors and skipped


Conclusion

Hope the article helped you in understanding and effectively use error handling inside a subflow for the appropriate use case. I will come up with a different topic for my next article. Till then stay tuned.

Node.js Plain text Reusability Test case Use case Execution (computing) Flow (web browser) Processing Testing Data Types

Opinions expressed by DZone contributors are their own.

Related

  • Munit: Parameterized Test Suite
  • Is It Okay To Stop Running Your Tests After the First Failure?
  • Projections/DTOs in Spring Data R2DBC
  • Event-Driven Order Processing Program

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

OSZAR »