-
Notifications
You must be signed in to change notification settings - Fork 416
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
fix(getMessages): Emit Error object in "error" event #1387
base: dev
Are you sure you want to change the base?
Conversation
It would probably be better to construct the error object, then overwrite the stack |
lib/Client.js
Outdated
@@ -2673,7 +2673,7 @@ class Client extends EventEmitter { | |||
try { | |||
return new Message(message, this); | |||
} catch(err) { | |||
this.emit("error", `Error creating message from channel messages\n${err.stack}\n${JSON.stringify(messages)}`); | |||
this.emit("error", new Error(`Error creating message from channel messages\n${err.stack}\n${JSON.stringify(messages)}`)); |
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.emit("error", new Error(`Error creating message from channel messages\n${err.stack}\n${JSON.stringify(messages)}`)); | |
err.message = `Error creating message from channel messages\n${JSON.stringify(messages)}`; | |
this.emit("error", err); |
Error
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.
options.cause was added in node 16.9.0, we're currently on v10 (v14 at the latest), so we cannot use it
Went with your original suggestion. Thanks. |
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.
Setting .message
doesn't affect .stack
. TBH I don't think the full JSON belongs in the error message. warn
(also not great) and debug
events are used to log JSON for other parsing errors
We can slice the first line off the stack and remake it with the new message or we can just ignore the original stack and construct a new error |
Any other alternatives to this? Current solution (although error might be hard to read) is the best one imo |
Didn't really know how to title this, apologies if I got it wrong.
Error event
err
param should be typeError
- https://github.com/abalabahaha/eris/blob/dev/index.d.ts#L711