All built-in errors have a default handler they use when they are returned. However, you might want to change how errors look or behave in certain situations.
If you want to change how InternalError
s are logged, or if you want to use an error tracker like sentry, you can change the errors.Log
function:
All error handlers that send error messages to the user use the error and info embeds provided by package errors
. So to change the looks of errors it's often easier to simply alter the embeds using errors.SetErrorEmbed
and errors.SetInfoEmbed
instead of changing every error handler.
If you're using localization, make sure to define fallbacks for all text used in the embeds. Otherwise, errors might not get sent, if localization fails.
If you want to change how certain error types are handled, you can replace the handler function of the error. Every error (except InformationalError
) has a handler function titled Handle{{error_name}}
. You can use the default handler as a reference.
If you want to change how individual errors are handled, the correct place is the bot's error handler. You can change it by setting a custom one in the bots bot.Options
.
If you simply want to ignore errors, you can just filter those out and then call bot.DefaultErrorHandler
.