-
Notifications
You must be signed in to change notification settings - Fork 1
Define message for non-Error errors
#69
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
Conversation
message for non-Error errors
|
I was able to make the message guessing function more complex, so now it should return something like this: // For a number 123
> console.log(composeMessage(e));
Non-error literal 123 was thrown
// For regular messages
> console.log(composeMessage(e));
this was the error message
// For objects, like ReadableStream or Array
> console.log(composeMessage(e));
Non-error object ReadableStream was thrownI'm not too happy about needing to make a separate function to handle this logic as it won't fit in one line, and is required to be repeated, so this can't be defined where needed. Rather, I had to define Thoughts, @tegefaulkes? |
|
All the tasks have been completed, and this PR has been approved. Merging. |
|
Generally I prefer not to make application concerns a library functionality. The exact reporting of a message - specifically it's template or toString impl should be generic and allowed to be overridden by the downstream user. This is how you ensure reusable modules/libraries. |
Should I make an issue to track this? |
|
If you think about the levels of genericity:
|
Description
If a non-
Errorerror is thrown from within a RPC handler, themessagefield would be undefined. This would result in themessagefield (which is expected to be present) be omitted, breaking the parsing step.This PR addresses that by wrapping that in a nicer message. For example, if we do
throw 123, the message becomes'Non-error class Number was thrown'. If we dothrow new ReadableStream(), then the message becomes'Non-error class ReadableStream was thrown'. You get the idea.Issues Fixed
VaultOpserrors inErrorPolykeyerrors and updating tests Polykey#838Tasks
Final checklist