HandleRecovery handles the common logic for recovering from a panic.
(logger *zap.Logger, r interface{}, errMsg string)
| 436 | |
| 437 | // HandleRecovery handles the common logic for recovering from a panic. |
| 438 | func HandleRecovery(logger *zap.Logger, r interface{}, errMsg string) { |
| 439 | err := attachLogFileToSentry(logger, "./keploy-logs.txt") |
| 440 | if err != nil { |
| 441 | LogError(logger, err, "failed to attach log file to sentry") |
| 442 | } |
| 443 | sentry.CaptureException(errors.New(fmt.Sprint(r))) |
| 444 | // Get the stack trace |
| 445 | stackTrace := debug.Stack() |
| 446 | LogError(logger, nil, errMsg, zap.String("stack trace", string(stackTrace))) |
| 447 | } |
| 448 | |
| 449 | // Recover recovers from a panic and logs the stack trace to Sentry. |
| 450 | // It also stops the global context. |
no test coverage detected