Skip to content

fix(v2/runtime): wrap string error rejections in Error objects#5200

Draft
leaanthony wants to merge 1 commit intomasterfrom
v2-bugfix/4379-bindings-error-objects
Draft

fix(v2/runtime): wrap string error rejections in Error objects#5200
leaanthony wants to merge 1 commit intomasterfrom
v2-bugfix/4379-bindings-error-objects

Conversation

@leaanthony
Copy link
Copy Markdown
Member

Summary

Fixes #4379

Promise rejections from Go binding calls now wrap string errors in proper Error objects instead of rejecting with raw strings.

Problem

When a Go method returns an error, the Wails runtime rejects the JS promise with a plain string. Libraries like TanStack Query expect Error instances (they access error.message), making the bindings incompatible.

Fix

In Callback(), wrap message.error in new Error() when it's a string, and pass through non-string errors as-is.

Testing

  • v2/test/4379/calls_test.mjs — 7 tests, all passing:
    • String error → Error instance with message and stack
    • Successful result still works
    • Non-string error objects are passed through as-is

Promise rejections from Go binding calls now wrap string errors in
proper Error objects, enabling compatibility with error-handling
libraries like TanStack Query that expect Error instances.

Fixes #4379
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 21, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e40c3a98-b396-465e-889a-d90622a15d73

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch v2-bugfix/4379-bindings-error-objects

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Frontend bindings does not return "Error" object on errors, only strings

1 participant