Skip to content

Commit 2b7c400

Browse files
committed
tweak: make zod error more prompty
1 parent 1a227b5 commit 2b7c400

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

packages/opencode/src/tool/tool.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,12 @@ export namespace Tool {
5050
toolInfo.parameters.parse(args)
5151
} catch (error) {
5252
if (error instanceof z.ZodError && toolInfo.formatValidationError) {
53-
throw new Error(toolInfo.formatValidationError(error))
53+
throw new Error(toolInfo.formatValidationError(error), { cause: error })
5454
}
55-
throw error
55+
throw new Error(
56+
`The ${id} tool was called with invalid arguments: ${error}.\nPlease rewrite the input so it satisfies the expected schema.`,
57+
{ cause: error },
58+
)
5659
}
5760
return execute(args, ctx)
5861
}

0 commit comments

Comments
 (0)