Skip to content

Commit 88f12b0

Browse files
committed
core: prevent TypeError when error handling encounters non-object errors
When API errors like token limit exceeded errors are passed as strings to error checking methods, the 'in' operator would throw a TypeError. This fix adds a type guard to check that the input is an object before attempting to access its properties, allowing proper error classification even when encountering unexpected error formats from providers.
1 parent 54af7f9 commit 88f12b0

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

packages/opencode/src/util/error.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export abstract class NamedError extends Error {
2727
}
2828

2929
static isInstance(input: any): input is InstanceType<typeof result> {
30-
return "name" in input && input.name === name
30+
return typeof input === "object" && "name" in input && input.name === name
3131
}
3232

3333
schema() {

0 commit comments

Comments
 (0)