Either directly pass a RecoveryMessage or pass a RecoveryHandler, a function that gives you access to the panic error, manipulate it as needed, maybe even send an alert somewhere and then return a response string that's sent as the server response.
Here's sample use case
// create server
if err := barf.Stark(barf.Augment{
Logging: barf.Allow(), // enable request logging
Recovery: barf.Allow(), // enable panic recovery so barf returns a 500 error instead of crashing
RecoveryHandler: func (err error) string {
return err.String()
},
RecoveryMessage: "Something went wrong",
}); err != nil {
barf.Logger().Error(err.Error())
os.Exit(1)
}
Either directly pass a
RecoveryMessageor pass aRecoveryHandler, a function that gives you access to the panic error, manipulate it as needed, maybe even send an alert somewhere and then return a response string that's sent as the server response.Here's sample use case