Intermediate
Error Handling Patterns in DSH
Error Handling Patterns in DSH — Learn how to build intermediate dsh plugins.
Errors must surface to the model
When a tool fails, return { ok: false, error: string } — never throw. Thrown errors crash the model call and produce unhelpful messages.
async execute(args) {
try {
const result = await doSomething(args.input);
return { ok: true, data: result };
} catch (err) {
return { ok: false, error: String(err) };
}
}The model can then decide to retry, ask the user for clarification, or report the error gracefully.