Errors

Produce human-friendly errors from your tasks
When a task fails, surfacing an error message to the user who ran your task can help them debug what went wrong without spelunking through logs or pinging the engineering team. Airplane supports a convention for producing errors from tasks that integrates with the rest of Airplane.

Data model

Errors are returned from tasks through Output via the following convention:
json
Copied
1
{
2
"error": "Your error message here..."
3
}

Rendering

If a task produced an error, the output UI will render the error's message:

Producing errors

Errors can be produced by throwing an error. All uncaught errors will be automatically converted into error output and a stack trace will be printed in the run logs. When a task fails, any ongoing child tasks will be cancelled.
typescript
Copied
1
export default async function (params) {
2
if (!isValidEmail(params.email)) {
3
// Errors like this will be converted to error output automatically:
4
throw new Error(`Expected a valid email address: got ${params.email}`);
5
}
6
7
try {
8
const run = await airplane.sql.query(/** ... */);
9
// ...
10
} catch (err) {
11
// You can catch errors to handle or ignore them.
12
// ...
13
}
14
}