Improve error debugging

As you can see in the screenshot, I have an interaction handler that runs the various handlers of my slash commands, like autocomplete. There's a bug in the code causing the debugger to stop (break on caught and uncaught exceptions). The problem is that I can't tell from the call stack where this error was originally thrown. I don't know if this is because of how I load commands dynamically similar to the docs or because of the underlying EventEmitter. How can I change my code so I can see in the call stack where the error originates from in my code? I'm not talking about "error handling" - this is only for debugging and not for output for users. I'd also prefer not to litter my code with individual try-catch blocks.
6 Replies
d.js toolkit
d.js toolkit2w ago
functiondj
functiondjOP2w ago
No description
Unknown User
Unknown User2w ago
Message Not Public
Sign In & Join Server To View
monbrey
monbrey2w ago
You should probably just log the error instead of throwing it again Why catch it just to rethrow it?
functiondj
functiondjOP2w ago
that was just to make sure that break on [un]caught exceptions doesn't break outside the interactionCreate handler. to narrow it down a little bit the error is caused by failed schema validation. it's only useful with a stack trace that tells me where the error was thrown. ok, thanks moving to https://discord.com/channels/222078108977594368/1438327155200233562
d.js toolkit
d.js toolkit2w ago
The thread owner has marked this issue as solved.

Did you find this page helpful?