Add panic recovery, switch some fatal raises to panic

I don't know what I am doing really
This commit is contained in:
2024-02-16 17:28:32 -06:00
parent 595228df15
commit 069b77aebe
4 changed files with 26 additions and 15 deletions

13
main.go
View File

@@ -223,6 +223,19 @@ func main() {
// Log command invocation
event.Msg("Command Invoked")
// Prepare to recover
defer func() {
if err := recover(); err != nil {
log.Error().Stack().Str("commandName", name).Interface("detail", err).Msg("Command Handler Panic")
// Respond with error
err := RespondError(internalSession, interaction.Interaction, "Unexpected Error: command handler panic", nil)
if err != nil {
log.Error().Stack().Str("commandName", name).Err(err).Msg("Failed to respond with panic error feedback")
}
}
}()
// Call handler
err := handler(internalSession, interaction)