fix(opencode): expand Error properties in logs for better diagnostics#12809
fix(opencode): expand Error properties in logs for better diagnostics#12809Haoping-Xiao wants to merge 1 commit intoanomalyco:devfrom
Conversation
|
The following comment was made by an LLM, it may be inaccurate: No duplicate PRs found |
|
with this fix: before:
after:
before:
after:
|
|
@rekram1-node could you please help review this PR? I believe it will help reduce many unnecessary issues. Please let me know if you have any suggestions—I’ll be happy to contribute. |
Fixes #12808
What
Error logs previously only printed
e.message, losing structured context likeproviderID,modelID,url,statusCode,causechain, and stack traces.Changes
formatErrorinlog.tsnow expands all own properties of an Error viaObject.getOwnPropertyNames, recursing into nested Errors (e.g.cause)buildcallsformatErrorwhen a value is aninstanceof Error, emitting each property as a separatekey=valuepairunhandledRejection/uncaughtExceptionhandlers inindex.ts,worker.ts,thread.tsto pass the full error object instead ofe.messageeinstead ofe.messagefetchResourcesForClientlogged "failed to get prompts" instead of "failed to get resources"Backward compatible
Callers that still pass
e.message(a string) work exactly as before. Only callers that pass an Error object get richer output.Verification
bun run typecheckpassesERROR ... e=ProviderModelNotFoundError rejectionERROR ... name=ProviderModelNotFoundError message=ProviderModelNotFoundError data={"providerID":"openai","modelID":"gpt-5-turbo"} stack=... rejection