API Testing and Monitoring: Recommended by Our Developers

Could error handlers be a good strategy for API testing and monitoring? Our developers are sharing their secrets! Protect automated tasks and prevent issues.

May 2, 2024

Imagine a scenario where a crucial part of your process faces an issue. Without error handlers, this small problem could quickly turn into a big mess, causing everything to stop and delaying your work. But by using error handlers, you could prevent these problems from getting bigger. They keep automated systems strong and dependable, even when things don't go as planned. Here's how error handlers work and why they're so important for keeping our projects on track.

Error Handling in Make: A Practical Scenario

This scenario was specifically designed within Make to illustrate how error handlers function. In this scenario, a module from 0CodeKit is tasked with determining a person's gender based on their name. The goal is to show how error handlers can manage situations where the module encounters unexpected data or fails to retrieve necessary information.

Now, it might occur that the name in question is unknown or not even a name but a word that shouldn't be in that field, causing the module to fail. Notice that the error is clear - the name is not in the database - but it's still an error. The issue with errors is that they interrupt the automation flow, preventing everything after the failed module from triggering. To avoid this, we use Error Handlers.

There's a variety of native Error Handlers in Make, but one can also construct their own execution flow in case of an error. To build an 'error handling path' from a module - meaning the path the automation will take if this module fails, you do a right-click on the module and select "Add Error handler".

Visually, it appears as another branch of the workflow. The key is that it will only activate if the module throws an error. In our example, we could use the error handler to execute a case where we send an email using neutral words that do not provide information about the person's gender. So, if the module fails to detect the gender from the name, the email would still be sent, just in a more impersonal manner.

For this purpose, a simple alternative would be to use the "Resume" error handler offered by Make. This error handler allows us to assign default values to the fields that the failed module should have completed. In our case, we can assign a default value of "unisex" to the gender field. This way, every time the module fails to find the name, the automation would naturally follow the 'unisex' branch, never throwing an error that breaks the Scenario.

Other Error Handler Options

Error handling is like a safety net for automated processes. It helps keep things running smoothly even when things go wrong. Imagine running a scenario, and something unexpected happens. Instead of everything stopping suddenly, error handlers could. These are other error handler options:

  • Ignore: This one simply ignores errors and lets the scenario keep going. It's great when small mistakes won't affect the whole process.
  • Resume: When there's an error, Resume steps in with a backup plan. It could be swapped for a substitute so the scenario can carry on without a hitch, for example.
  • Commit: This one hits pause to save changes in a database. But it only does this if the scenario involves certain types of database operations.
  • Rollback: Rollback undoes changes made by certain modules, like an 'undo' button. But it can't undo everything, only certain types of actions.
  • Break: This one removes any problematic parts of the scenario. It keeps track of what went wrong so you can come back and fix it later. Depending on settings, Make might finish up these scenarios or save them for later fixing.

Closing Remarks

In summary, error handlers ensure that automated tasks keep running smoothly even if something unexpected happens. They stop small problems from turning into big ones and help automated systems stay reliable. In the practical scenario we talked about in Make, we saw how error handlers can deal with errors or missing information in modules. Moreover, there are different types of error handlers we can use, like Ignore, Resume, Commit, Rollback, and Break, each with its own way of handling problems.

*Note that n8n and Zapier offer error handling options as well*

What’s a Rich Text element?

The rich text element allows you to create and format headings, paragraphs, blockquotes, images, and video all in one place instead of having to add and format them individually. Just double-click and easily create content.

Static and dynamic content editing

A rich text element can be used with static or dynamic content. For static content, just drop it into any page and begin editing. For dynamic content, add a rich text field to any collection and then connect a rich text element to that field in the settings panel. Voila!

How to customize formatting for each rich text

Headings, paragraphs, blockquotes, figures, images, and figure captions can all be styled after a class is added to the rich text element using the "When inside of" nested selector system.