Skip to content

🐛 wrap non-Error causes passed to Err()#1165

Closed
rauhryan wants to merge 1 commit intothefrontside:v4from
rauhryan:rr/err-unknown-cause
Closed

🐛 wrap non-Error causes passed to Err()#1165
rauhryan wants to merge 1 commit intothefrontside:v4from
rauhryan:rr/err-unknown-cause

Conversation

@rauhryan
Copy link
Copy Markdown
Contributor

@rauhryan rauhryan commented May 7, 2026

Motivation

Err() currently accepts Error, but JavaScript catch blocks and promise rejections can produce unknown thrown values. That makes it awkward to pass caught values directly to Err() and can leak non-Error throw values through APIs that model failures as Error.

This splits the Err() behavior change out so it can target the same base branch as #1149.

Approach

  • change Err() to accept unknown
  • preserve existing Error instances as-is
  • wrap non-Error causes in ThrowValueError(String(cause), { cause })
  • remove internal as Error casts where caught values are passed to Err()
  • add regression coverage for Err() and until(Promise.reject(...))

@cowboyd
Copy link
Copy Markdown
Member

cowboyd commented May 9, 2026

This has been superseded by #1149

@cowboyd cowboyd closed this May 9, 2026
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.

2 participants