Skip to main content
All CollectionsTroubeshooting
HowTo manage error handling in HTTP requests
HowTo manage error handling in HTTP requests

In this article, you'll learn how to catch errors when occurred in HTTP request events.

Robert van Boesschoten avatar
Written by Robert van Boesschoten
Updated over a year ago

Warning!

This is a legacy document. The features described below are only usable within the classic-generation environment.

Currently, Betty Blocks offers faster and more advanced options that are available in next-gen. Before you start working on some new features in your application, consider doing it using the next-gen version. In particular, you might find it useful to check out Using the HTTPS action step article.

Good luck!


After reading this article you will know:

  • How to get the error information

  • How to setup basic error handling

Error info as

When creating an HTTP request you'll notice that you can set the Error info as variable. This variable collects error information about the request, which can then be used for the remainder of the action.

The variable is treated as an Object, where 2 attributes can be accessed, containing the information. The 2 attributes are:

  • success: Was the request successful? Returns true or false.

  • message: The (error) message the webservice returned.

The data is stored in JSON:

{"success":false,"message":"Failed to reach web service within 20 seconds"}

In case the request is successful, this variable will be blank, as no error turned up.
For the remainder of this article, we'll refer to this variable as var:error_info.

Getting the error information

As explained above, the information is stored as JSON data in the variable. To access the attributes and their values, you'll need 2 additional variables.

Success

To access the value in the success attribute, create a Checkbox expression variable.
Call the variable success, and enter the following expression.

var:error_info[success]

You can use this variable in Conditions or other events to check if the request was successful.

Message

To access the value in the message attribute, create a Text expression variable.
Call the variable message, and enter the following expression.

var:error_info[message]

You can use this variable in Conditions events to check what kind of error you received and in Create/Update events to save the error in a Text property!

Setting up error handling

When the request has failed, the success variable we just created will return false. You can use this in a condition to setup a different action for when an error occurs. In the example below, we send an email to a developer about whether or not the request completed succesfully.

Did this answer your question?