How to test for errors on a Task in Application Integration

UPDATE:  We have a feature called Error Catcher which will give you many more options for handling errors that the one use case I describe here in this post.  Please check out the Error Catcher first! 

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Here is a summary for how to test for errors that may have happened on a task in Application integration.

Summary:

  • Create a local variable called ErrorMessage of type String
  • Set the Retry on Failure to "Ignore" for sync execution for the task you want to check
  • Add this condition on the Edge after the task for the Error edge:   exists($ErrorMessage$)
  • Add this condition on the Edge after the task for the Success edge:   NOT exists($ErrorMessage$)

Here is a screenshot of a simple example Integration showing how you can branch after a Data Mapper task to a Success or Error edge condition:

Screenshot 2023-05-02 at 9.40.31 AM.png

This is the ErrorMessage local string variable that I created

Screenshot 2023-05-02 at 9.40.55 AM.png

And, here are the edge conditions for the Error and Success edges:

Screenshot 2023-05-02 at 9.42.33 AM.pngScreenshot 2023-05-02 at 9.43.09 AM.png

For this integration, I tested with a simple string array as an input to the API Trigger.  If I send in 2 elements, the data mapper fails because it is doing a mapping rule that references the third element, which routes to the Error edge condition. If I send in 3 elements, then it executes successfully and follows the success edge condition.  Here is the mapping rule referencing the 3rd element : string_array.GET ("2") since indexes are zero based:

Screenshot 2023-05-02 at 9.47.09 AM.png

Here is the test input for the failure condition that only has 2 elements in the string_array

Screenshot 2023-05-02 at 9.49.32 AM.png

Here is a successful Test input with 3 elements.

Screenshot 2023-05-02 at 9.49.54 AM.png

1 9 827
9 REPLIES 9

Hi, I have a use case where I retry on a task 3 times when it fails - is there anyway I can handle the error after the task has been tried and failed 3 times rather than it failing?

Former Community Member
Not applicable

At this point we don't have the ability to execute logic after the set number of retries have completed and the integration has still not succeeded. This is on the roadmap.

Is this implemented now?

Pls check this: https://cloud.google.com/application-integration/docs/configure-error-catcher-trigger. You should be able to handle errors using this new feature and execute set of tasks...

Hi Shaaland
is it possible to turn the $ErrorMessage$ into a JSON variable?
I have the following returning in the error message and I only really need the "message" part:

'HTTP Response Errors: 400 Bad Request x-mashery-message-id: 3f403125-551d-43fb-9e19-cc735857d05a x-mashery-responder: 50-rt10 strict-transport-security: max-age=15552000; includeSubDomains; preload Content-Security-Policy: upgrade-insecure-requests x-xss-protection: 1; mode=block x-frame-options: DENY x-content-type-options: nosniff cache-control: no-cache, must-revalidate, max-age=0, no-store, private Referrer-Policy: strict-origin-when-cross-origin Vary: Origin, X-HTTP-Method-Override Content-Length: 164 Content-Type: application/json; charset=UTF-8 Date: Tue, 22 Aug 2023 14:05:06 GMT Connection: keep-alive Keep-Alive: timeout=5

{"message":"The event data contains duplicate value for an existing primary key. Please correct the event data and try again.","errorcode":30000,"documentation":""}'

Hi StuartLayton, 

Yeah, It's possible to get the $ErrorMessage$ into a JSON variable. To do this you firstly need to set the `Error handling strategy` for ignore for your respect mode of execution i.e. `Sync` or `Async`. As shown below in the screenshot. And create a local variable with the `ErrorMessage` name as mentioned in the post. 
 

deepgoel_0-1694152226220.png

Then you can use data mapping task/JS task/ Data Transformer task on the ErrorMessage Variable to convert the value to JSON format. 
Based on you sample text. We can use a Data mapping task. Firstly, you can use a SPLIT function on the newline and then can get the JSON object in string use GET. Then use TO_JSON to convert the string into the JSON variable. 

I hope this helps with your query.


I've got a similar format error message to StuartLayton but I'm struggling to get the Split() function to work on the newline.

Any hints would be welcome.

Thanks

 

Hi, 

You can use `Enter`/`Return` key on your keyboard to split via newline. 

deepgoel_0-1701713133683.png

Hi Dan

I had to split my ErrorMessage at the { curly bracket then do a load of giggery to get it back into a decent format. It might help you?

See Below:

StuartLayton_0-1701936906955.png

The output I get is this:

StuartLayton_1-1701936949767.png