Browse Source

fix: error logging (#2165)

Aiden Cline 6 months ago
parent
commit
4fadbcfb90
1 changed files with 6 additions and 1 deletions
  1. 6 1
      packages/opencode/src/util/log.ts

+ 6 - 1
packages/opencode/src/util/log.ts

@@ -101,7 +101,12 @@ export namespace Log {
         ...extra,
         ...extra,
       })
       })
         .filter(([_, value]) => value !== undefined && value !== null)
         .filter(([_, value]) => value !== undefined && value !== null)
-        .map(([key, value]) => `${key}=${typeof value === "object" ? JSON.stringify(value) : value}`)
+        .map(([key, value]) => {
+          const prefix = `${key}=`
+          if (value instanceof Error) return prefix + value.message
+          if (typeof value === "object") return prefix + JSON.stringify(value)
+          return prefix + value
+        })
         .join(" ")
         .join(" ")
       const next = new Date()
       const next = new Date()
       const diff = next.getTime() - last
       const diff = next.getTime() - last