Skip to content

Conversation

@adespawn
Copy link
Contributor

@adespawn adespawn commented Nov 7, 2025

The idea for this PR, is to include the name of the Rust error type, in the thrown error.
In the future, current approach can be extended to contain more information,
that cannot be passed with the current error handling implementation.

The other benefit of this PR is that all error construction will happen on the Rust side,
so we no longer need to remember which function may return errors, and handle them (see #216)

I turns out https://doc.rust-lang.org/std/ops/trait.FromResidual.html is still experimental.

If this were to be merged, after updating all places where we return napi::Error, this would fix:

Fixes #119
Fixes #216 (We update the whole process, so this is no longer necessary)

This commit adds support for custom errors. The new logic allows
for setting additional values inside the JS error object,
compared to Errors exposed by the napi-rs, that allows only setting
error message and kind. This is intended to be a easy replacement
of the current errors with only minor refactor required.
This can be done through some macro,
instead of doing it manually, but I wanted to validate the idea,
before doing so.
@adespawn
Copy link
Contributor Author

@wprzytula If you could look at it, to make sure the general idea makes sens, before I update all the error handling to this new format

@adespawn adespawn requested a review from wprzytula November 12, 2025 08:25
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.

Incorrect usage of the error throwing wrapper Add support for throwing errors with special parameters from napi

1 participant