DSH Quality
Intermediate
3 min read

Error Handling Patterns in DSH

Error Handling Patterns in DSH — Learn how to build intermediate dsh plugins.

Last updated: 2026-08-26

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.

ts
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.