Skip to main content

Error handling

When an error is thrown during the execution of an action, Interval will catch it and display an "error" completion state to the person running your action.

In practice, this means you can safely throw errors inside your action code without writing additional try/catch blocks.

By example, the following code:

import Interval from "@interval/sdk";

new Interval({
apiKey: "<YOUR API KEY>", // get an API key at https://interval.com/dashboard/develop/keys
routes: {
error_example: async () => {
throw new Error("Something went wrong!");
},
},
}).listen();

Would cause this message to be displayed to the person running your action:

Errors in pages‚Äč

Interval will also catch and display any error within a page handler function.

Errors thrown in a function passed to populate the title or description of a page's Layout will also be caught and displayed, but the rest of the page will display as usual.

Was this section useful?
On this page