Customized error handling in webMethods.io Integration
Tags: errorhandler, integration, tutorial
Published: 2022-09-23 08:46:19

---
title: Customized error handling in webMethods.io Integration
published: true
date: 2022-07-28 08:24:00 UTC
tags: errorhandler, integration, tutorial
canonical_url: https://tech.forums.softwareag.com/t/customized-error-handling-in-webmethods-io-integration/259280
---

 

**In the [webMethods.io](http://webMethods.io) Integration scenarios, we would be required to handle the errors that occur during run time in workflows or flow services. The errors should be handled and logged appropriately or sent as response to the source system that initiated the call to [webMethods.io](http://webMethods.io) integration.**

[![error handling 1](https://aws1.discourse-cdn.com/techcommunity/optimized/3X/d/9/d9263d0dd0344c0c7b730e7baded38ad64d1134d_2_690x383.jpeg)](https://aws1.discourse-cdn.com/techcommunity/original/3X/d/9/d9263d0dd0344c0c7b730e7baded38ad64d1134d.jpeg "error handling 1")

## Why to do error handling & logging?

- To identify the root cause of errors.
- For generating alerts upon errors from the system.
- Source or target systems to be informed of the respective errors in the integration flow.
- Avoid situations like getting into infinite loop or heavy utilization of existing resources etc.

## Where to do error handling & logging?

- Workflows.
- Flow services.
- Workflows involving Flow services
- Hybrid flow: Workflows with on-prem connectors.

## What to use for the implementation?

- For Workflows

| Step | Usage |
| --- | --- |
| Logger | To log the relevant information to [webMethods.io](http://webMethods.io) logs. |
| JSON Customizer | To customize the JSON data in the flow or the response. |
| Return Data on Sync Webhook | To send the error response to the caller. |
| Send Email | To generate email in workflows. |
| Set Workflow Status Failed | To explicitly set the status of Workflow as Failed. When Global Error Handler is used, the status of Workflow would always be indicated as “Success,” and it would cause huge effort to identify the workflow instances that failed. |

- For flow services

| Step | Usage |
| --- | --- |
| Try-Catch Block | To handle the exceptions in catch block. |
| Throw error | To throw exception in the flow service. |
| getLastError | To get the last error that occurred. |
| logCustomMessage | To log the custom message to [webMethods.io](http://webMethods.io) logs. |
| SMTP Connector | To generate emails. |
| On-prem connector | This is useful in scenarios where we would have the hybrid connection to the on-prem system. We can have the error handling framework in the internal IS and we could invoke the respective service as an on-prem connector. We need to make a note that this could result in additional network traffic when we call the on-prem system. |

## How Should We Implement?

The custom error code to be captured at specific step in the flow are customized using **JSON parser**. Please note that the below workflow steps as indicated here in the screenshot are only for demonstration purpose and not compulsory.

[![error handling 2](https://aws1.discourse-cdn.com/techcommunity/optimized/3X/6/d/6d53fc84376aaa6a6d14f8fb9a6219eb19b14f9e_2_690x261.jpeg)](https://aws1.discourse-cdn.com/techcommunity/original/3X/6/d/6d53fc84376aaa6a6d14f8fb9a6219eb19b14f9e.jpeg "error handling 2")

The custom error message is extracted from the previous step of error handler (in this example createAlarm).

[![error handling 3](https://aws1.discourse-cdn.com/techcommunity/optimized/3X/e/0/e003b38b6e5a34fdcc804c8c4aeb7cbece843f80_2_690x283.jpeg)](https://aws1.discourse-cdn.com/techcommunity/original/3X/e/0/e003b38b6e5a34fdcc804c8c4aeb7cbece843f80.jpeg "error handling 3")

The custom error codes are stored in the project parameters which are used for the mapping.

[![error handling 4](https://aws1.discourse-cdn.com/techcommunity/optimized/3X/0/2/02f2a869894976b35a97ac6fd3e5eaa329b31be4_2_690x319.jpeg)](https://aws1.discourse-cdn.com/techcommunity/original/3X/0/2/02f2a869894976b35a97ac6fd3e5eaa329b31be4.jpeg "error handling 4")

Error logging in monitor: this is how the error logs will look like in [webMethods.io](http://webMethods.io) monitor.

[![error handling 5](https://aws1.discourse-cdn.com/techcommunity/optimized/3X/d/2/d25753ba9ee19907914a10d6f7d1d4380802e9f1_2_690x394.jpeg)](https://aws1.discourse-cdn.com/techcommunity/original/3X/d/2/d25753ba9ee19907914a10d6f7d1d4380802e9f1.jpeg "error handling 5")

* * *

> This article is part of the TECHniques newsletter blog - technical tips and tricks for the Software AG community. [Subscribe](https://info.softwareag.com/TechCommunity-Subscription-Page.html) to receive our quarterly updates or read the [latest issue](https://tech.forums.softwareag.com/techniques-latest).

[Read full topic](https://tech.forums.softwareag.com/t/customized-error-handling-in-webmethods-io-integration/259280)