-
Notifications
You must be signed in to change notification settings - Fork 29
error_data #333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
error_data #333
Conversation
|
Yeah, I've been unsure how best to expose the new information in Up to now, I've taken the approach of checking for errors in the C layer and throwing exceptions across the C/JS boundary instead of returning a value (e.g. I think this is still the right approach for the Checking for errors and throwing exceptions across the C/JS boundary works fine when the only information that needs to be conveyed is the error message, because the Napi::Error class supports this. But Some options:
I'm not inclined to take this third option. Either of the first two seem reasonable. Certainly the least effort is the second, not only because it's the one you've implemented in this PR, but also because it doesn't change any existing APIs. The only downside is the somewhat strange API, where the thrown exception doesn't contain all relevant information, and a separate function call is required to get the additional information. I'd be interested to explore whether a custom Regardless of which approach we take at the If we're able to create a custom So, before going too far with |
|
sure, I can play around with it. I also don't see any way to do exception->custom JS error, but you can attach arbitrary keys to the exception that get carried over, so there is some opportunity to do error checks in C. Perhaps error wrapping could be avoided with hacked types.. |
Attempts to implement #296
Based on comment here, this might not be the correct approach (for api/ specifically?):
This PR just takes the expose-directly approach.
Some of the tests assert against errors thrown by appenders, so maybe you're thinking of integrating the error codes into that process more natively?