-
Notifications
You must be signed in to change notification settings - Fork 7
Expose underlying JS Errors #363
base: main
Are you sure you want to change the base?
Conversation
#[derive(Debug, PartialEq)] | ||
pub enum ValidateIndexDefinitionError { | ||
MissingName, | ||
MissingKeyPrefix, | ||
MissingIndexPath, | ||
} | ||
|
||
impl ToJsValue for ValidateIndexDefinitionError { | ||
fn to_js(&self) -> Option<&JsValue> { | ||
match self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could just return None but by using a match it will be a compile error if the enum changes
A few concerns with this:
|
All good questions.
I think the experience we had with our customer over the last weeks shows that we really need to expose the underlying JS exception for error reporting to be meaningful. Could it be done in a simpler way? Maybe? Maybe a custom derive would make things easier to use but I feel like figuring out how to do custom derives is more work than it is worth. |
I was thinking about this. I think this is the right approach. If you imagine future non-js host environments, they are all going to have this problem of wanting to communicate the "cause" exception in the host system. Could we sub |
I'll bring this up to date... |
At the top level in connection.rs when we return a JS Error to JS, we now extract any possible inner JS error and add it as the `cause` property to the JS Error. Fixes rocicorp#352
At the top level in connection.rs when we return a JS Error to JS, we
now extract any possible inner JS error and add it as the
cause
property to the JS Error.
Fixes #352