Recover recovers from a panic and logs the stack trace to Sentry. It also stops the global context.
(logger *zap.Logger)
| 449 | // Recover recovers from a panic and logs the stack trace to Sentry. |
| 450 | // It also stops the global context. |
| 451 | func Recover(logger *zap.Logger) { |
| 452 | if logger == nil { |
| 453 | fmt.Println(Emoji + "Failed to recover from panic. Logger is nil.") |
| 454 | return |
| 455 | } |
| 456 | sentry.Flush(2 * time.Second) |
| 457 | if r := recover(); r != nil { |
| 458 | HandleRecovery(logger, r, "Recovered from panic") |
| 459 | err := Stop(logger, fmt.Sprintf("Recovered from: %s", r)) |
| 460 | if err != nil { |
| 461 | LogError(logger, err, "failed to stop the global context") |
| 462 | } |
| 463 | sentry.Flush(2 * time.Second) |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | // GenerateGithubActions generates a GitHub Actions workflow file for Keploy |
| 468 | func GenerateGithubActions(logger *zap.Logger, appCmd string) { |
no test coverage detected