Template Error Handling
The SDK provides specific error types for template operations.
JavaScript/TypeScript:
typescript
import { AuthError, BuildError, FileUploadError } from "e2b";
try {
await Template.build(template, {
alias: "my-template",
});
} catch (error) {
if (error instanceof AuthError) {
console.error("Authentication failed:", error.message);
} else if (error instanceof FileUploadError) {
console.error("File upload failed:", error.message);
} else if (error instanceof BuildError) {
console.error("Build failed:", error.message);
}
}Python:
python
from e2b import Template, AuthError, BuildError, FileUploadError
try:
Template.build(template, alias="my-template")
except AuthError as e:
print(f"Authentication failed: {e}")
except FileUploadError as e:
print(f"File upload failed: {e}")
except BuildError as e:
print(f"Build failed: {e}")Error Types:
- AuthError: Authentication failed (invalid API key, expired credentials)
- FileUploadError: File upload failed during template build
- BuildError: Template build failed (compilation errors, invalid configuration)