-
Notifications
You must be signed in to change notification settings - Fork 426
Fixing ReferenceError in catch block #188
base: master
Are you sure you want to change the base?
Conversation
Sending error to channel results in a ReferenceError because cleaned is not defined in the catch block's scope. Replaced with sending the error's stack to resolve this.
@@ -109,7 +109,7 @@ client.on("messageCreate", async (message) => { | |||
message.channel.send(`\`\`\`js\n${cleaned}\n\`\`\``); | |||
} catch (err) { | |||
// Reply in the channel with our error | |||
message.channel.send(`\`ERROR\` \`\`\`xl\n${cleaned}\n\`\`\``); | |||
message.channel.send(`\`ERROR\` \`\`\`xl\n${err.stack}\n\`\`\``); |
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 doesn't send the actual error.
- err.stack is
string[]?
meaning it could be undefined.
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 doesn't send the actual error.
- err.stack is
string[]?
meaning it could be undefined.
Error#stack
does send the actual error message, plus the error stack.- Technically
err
is of typeunknown
, so an instance check forError
would be appropriate here, but the chances of a non-error type being thrown is unlikely.
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.
@RealShadowNova... oops; implementation issue with the way my stack system works. soz!
can you screenshot what actually happens? |
As You could always just send the plain Error, but that will not provide any information regarding the actual location of the error, just the type and message associated with it. |
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 needs to be merged lmao
Bump - why this isn't merged yet |
Because the guide, the bot, and the community are pretty much dead. |
Sending error to channel results in a ReferenceError because cleaned is not defined in the catch block's scope.
Replaced with sending the error's stack to resolve this.