How to pass error from custom apps as response in scenarios' errors

Hi everybody,
I would like to implement a better error handling system for my custom apps.
I created a custom app that implement API from a logistic service. The API has its own error messages that helps debug any problem, but the info about the error message from API service are not passed to Make.

For example: If I try to create a delivery with my app and I use the wrong ZIP code, the API server responds with a code 500 and Make notifies me a generic error.
The API server, though, sends info about the error like this:

        "body": {
            "errorFieldCode": "140",
            "errorTypeCode": "2",
            "errorMessage": "receiverZipCode invalid"
        }

When I got this kind of situation, I have to rerun the scenario with the devtools open in order to catch the actual response from the server to read what was the error.

How could I pass the server response body values to Make so I can just read the log instead of rerun everything?

Hi Giacomo,

Have you tried adding the error directive to the response in your module communication?

Essentially, you should be able to include something like this:

{
    "response": {
        "error": {
            "type": "RuntimeError",
            "message": "[{{statusCode}}] {{body.error.message}}",
            "400": {
                "type": "DataError",
                "message": "[{{statusCode}}] {{body.error.message}}"
            },
            "500": {
                "type": "DataError",
                "message": "[{{statusCode}}] {{body.errorFieldCode}} - {{body.errorTypeCode}} -  {{body.errorMessage}}"
            }
        }
    }
}

This should make the error appear in a readable format in the scenario execution history.

1 Like

Thank you for the reply.
I tried before, but somehow I got it all wrong the first time since now I succeeded.

That is the way to do it!

2 Likes