Error handling with API integration using REST

Hey there,

I am new to MAKE and am building an integration with my API. I am setting up my custom app, and it works fine; however, I’ve been struggling to fix an issue with error handling.

My API responses follow this pattern:

{
  "success": boolean,
  "error": text or null,
  "details": text or array, // only available if "error" has some data
  "data": json,
}

Module communication code:

As you can see I’ve added the “error” code everywhere to make sure that the error would appear, but still doesn’t appear anywhere.

{
    "url": "https://api.firecrawl.dev/v1/scrape",
    "body": "{{parameters}}",
    "method": "POST",
    "response": {
        "output": {
            "body": "{{body}}",
            "headers": "{{headers}}",
            "statusCode": "{{statusCode}}",
            "result":"{{body}}",
            "error": {
                "type": "RuntimeError",
                "message": "[{{statusCode}}] {{body.error.message}}",
                "400": {
                    "type": "DataError",
                    "message": "[{{statusCode}}] {{body.error.message}}"
                },
                "500": {
                    "type": "ConnectionError",
                    "message": "[{{statusCode}}] {{body.error.message}}"
                }
            }
        },
        "error": {
                "type": "RuntimeError",
                "message": "[{{statusCode}}] {{body.error.message}}",
                "400": {
                    "type": "DataError",
                    "message": "[{{statusCode}}] {{body.error.message}}"
                },
                "500": {
                    "type": "ConnectionError",
                    "message": "[{{statusCode}}] {{body.error.message}}"
                }
            }
    }
}

When testing, everything works fine when the API doesn’t return errors. However, when an error occurs, it only shows this:

Additionally, you can check the MAKE Dev Tools body response, which contains exactly what should be displayed to the user.

All help is welcome, thanks

Hi @Ademilson_Tonato and welcome to the Make Community!

The reason you are seein this is that your HTTP call returns error code 400. Make considers that as an error and throws an error without reading the response. If you don’t wan’t that to happen, set this option to “No” in the HTTP module:

L

Welcome to the Make community!

Instead of referencing {{body.error.message}} (which doesn’t exist),

  {
    "type": "RuntimeError",
    "message": "[{{statusCode}}] {{body.error.message}}"
  }

You should reference the details instead,

  {
    "type": "RuntimeError",
    "message": "[{{statusCode}}] {{ifempty(body.details.1.message; body.details)}}"
  }

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

Hello, thank you for answering, @samliew

Should I place this under
response → output → error,

response → error,

or both as I currently have it?

{
  "url": "https://api.firecrawl.dev/v1/scrape",
  "body": "{{parameters}}",
  "method": "POST",
  "response": {
      "output": {
          "body": "{{body}}",
          "headers": "{{headers}}",
          "statusCode": "{{statusCode}}",
          "result": "{{body}}",
	   
          // Should I place it here?
          "error": {
              "type": "RuntimeError",
              "message": "[{{statusCode}}] {{ifempty(body.details.1.message; body.details)}}",
              "400": {
                  "type": "DataError",
                  "message": "[{{statusCode}}] {{body.error.message}}"
              },
              "500": {
                  "type": "ConnectionError",
                  "message": "[{{statusCode}}] {{body.error.message}}"
              }
          }
      },

      // Or should I place it here?
      "error": {
        "type": "RuntimeError",
        "message": "[{{statusCode}}] {{ifempty(body.details.1.message; body.details)}}",
        "400": {
            "type": "DataError",
            "message": "[{{statusCode}}] {{body.error.message}}"
        },
        "500": {
            "type": "ConnectionError",
            "message": "[{{statusCode}}] {{body.error.message}}"
        }
      }
  }
}

response → error is correct.

For more information, see Error handling | Make Developer Hub

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.