Custom error class for sandbox operations.
class SandboxErrorSymbol for identifying sandbox error instances
Structured error code for programmatic handling
Error name for instanceof checks and logging
Type guard ā returns true if backend is a CompositeBackend.
Uses duck-typing on routePrefixes so it works across module boundaries
where instanceof may fail.
try {
await sandbox.execute("some command");
} catch (error) {
if (error instanceof SandboxError) {
switch (error.code) {
case "NOT_INITIALIZED":
await sandbox.initialize();
break;
case "COMMAND_TIMEOUT":
console.error("Command took too long");
break;
default:
throw error;
}
}
}