Build errors
Wrap Template.build when your application needs to report a reason, retry an upload, or stop the current job.
mjs
import { BuildError, FileUploadError, Template } from "@abox-dev/sdk";
const templateName = process.env.TEMPLATE_NAME ?? "failing-template";
const template = Template().fromBaseImage().runCmd("exit 23");
try {
await Template.build(template, templateName);
} catch (error) {
if (error instanceof FileUploadError) {
console.error(`Could not upload build files: ${error.message}`);
} else if (error instanceof BuildError) {
console.error(`Template build failed: ${error.message}`);
} else {
throw error;
}
}FileUploadError in JavaScript and FileUploadException in Python cover files sent by copy. They extend the general build error, so handle them first.
BuildError and BuildException mean the builder could not execute an instruction or complete the template. The message contains the available reason, while build logs identify the failing step.
Invalid API keys raise AuthenticationError in JavaScript and AuthenticationException in Python. Do not retry with the same key automatically; replace or correct the key first.