Error handling

The best way to deal with errors is to use an error handler. An error handler connects to a module with the error handling route. When the module outputs an error, the error handling route activates and runs the error handler.

When all errors are handled, Make keeps scheduling scenario runs instead of disabling the scenario.

Read more about error handling in Make:

Setting up an error handling for our demo API

When you were trying your new search module, you were probably experiencing error 401, but you didn't know why was that, if you didn't check Integromat DevTool. Since Make offers advanced error handling, you should set your app the way, so you could understand what is wrong with your module/scenario right away and use error handlers.

Enter your search module into your scenario and create a new connection with a random API key, if you haven't done so before. You should see the error:

Error 401 Before Implementing Error Handling

In DevTool, you should see this output:

Error in the DevTool

We need to make sure the error from the body of the response is returned in the module's output as well.

As you learned before, error handling should take part in base, since it is an element, which is shared among all modules and remote procedures. Therefore, open base and replace the current code with the code below:

{
	"baseUrl": "http://demo-api.integrokit.com/api/v1",
	"headers": {
		"api-token": "{{connection.apiKey}}"
		},
	"response": {
		 "error": {
            	     "message": "[{{statusCode}}] {{body.error}}"
        }},
	"log": {
		"sanitize": ["request.headers.api-token"]
	}
}

Notice, that a new element response with error handling was added.

Basically, we mapped the error parameter from the response body. So now, when an error is returned from the API, the error message contains the statusCode together with error wording.

Now, go to your scenario again, and execute the search module. You should now see the detailed wording of the error:

Error 401 with Detailed Wording after Implementing Error Handling

Notice, that the wording of the error is now available. Thanks to this, you know where is an error and how to solve/handle it.

Voila! You just learned all the basics of custom app development in Make!

If you want to continue in development of your custom apps, you can explore our docs and learn more!

Last updated