summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAiden Cline <[email protected]>2025-11-02 23:38:56 -0600
committerAiden Cline <[email protected]>2025-11-02 23:38:56 -0600
commit88f12b08223fa1c0ff5275c8cc2f96ed64e887ab (patch)
tree397962ebb08aab680b408202ec21ff98dacf2893
parent54af7f9e1801cfdbd329bd26d7462844f1adf4a6 (diff)
downloadopencode-88f12b08223fa1c0ff5275c8cc2f96ed64e887ab.tar.gz
opencode-88f12b08223fa1c0ff5275c8cc2f96ed64e887ab.zip
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.
-rw-r--r--packages/opencode/src/util/error.ts2
1 files changed, 1 insertions, 1 deletions
diff --git a/packages/opencode/src/util/error.ts b/packages/opencode/src/util/error.ts
index d488abb6c..12c27a0a7 100644
--- a/packages/opencode/src/util/error.ts
+++ b/packages/opencode/src/util/error.ts
@@ -27,7 +27,7 @@ export abstract class NamedError extends Error {
}
static isInstance(input: any): input is InstanceType<typeof result> {
- return "name" in input && input.name === name
+ return typeof input === "object" && "name" in input && input.name === name
}
schema() {