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, FileUploadException in Python, and *agentbox.FileUploadError in Go cover files sent by copy. Handle these specific failures first; Go selects them with errors.As.
BuildError, BuildException, and *agentbox.BuildError 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, AuthenticationException in Python, and *agentbox.AuthenticationError in Go. Do not retry with the same key automatically; replace or correct the key first.