Skip to content

fix: expose the raw SDK error on AiError.cause - #16

Merged
fdarian merged 2 commits into
mainfrom
claude/aierror-cause-446211
Nov 11, 2026
Merged

fdarian merged 2 commits into
mainfrom
claude/aierror-cause-446211

Conversation

@fdarian

@fdarian fdarian commented Nov 11, 2026

Copy link
Copy Markdown
Owner

Since 7.1.0, AiError carries a typed reason instead of message/cause, so AiError.cause is undefined. Consumers that walk .cause chains generically to find statusCode / responseBody (e.g. mockingbird's engine) stop finding them and have to special-case instanceof AiError.

This adds override get cause() returning this.reason.cause (the raw SDK error, after RetryError unwrapping). It is a prototype getter, not a constructor field: Effect's error constructor does not set an own cause, so nothing shadows it. Additive, shipped as a patch.

Tests: cause is the same object as reason.cause, is not an own property, and a generic .cause walker reaches statusCode and responseBody from an APICallError.

@vercel

vercel Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ai-effect-docs Ready Ready Preview Nov 11, 2026 2:36pm UTC

@fdarian
fdarian merged commit c7a7a16 into main Nov 11, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant