spike-2 / Spike-2

Server specific Discord bot
https://spike-2.github.io
1 stars 0 forks source link

Make Discord logging errors non-fatal #78

Closed brandoningli closed 2 years ago

brandoningli commented 2 years ago

Related bugs/feature requests

Describe the changes

Wraps Discord logging in a try/catch, then logs exceptions while sending to Discord webhook with a flag to not try to post to Discord.

Expected behavior

Any errors while logging to Discord should be non-fatal, and the stack trace should be logged to the other transports.

Screenshots

New npm dependencies

Testing Instructions

Not easily testable for the exact case we're worried about. What I did to make sure it should work as expected:

  1. Added the catch body to the try body (without trying to print the stack trace).
  2. Added an error log on bot start.
  3. Started the testing bot.
  4. The initial error logged to all transports. The subsequent simulated Discord logging error was only seen in the console and log file.

Additional context