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

For languages that support throwing errors (Node.js, Python), uncaught errors that bubble beyond the main method will be automatically converted into error output and a stack trace will be printed in the run logs.
javascript
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
}
For other task kinds, use Output directly by logging the following to stdout:
bash
Copied
1
airplane_output_set:error "Your error message here..."