Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Commit

Permalink
Early return in HTTP error handler
Browse files Browse the repository at this point in the history
  • Loading branch information
felipecruz91 committed Sep 15, 2022
1 parent a8fa812 commit 288ef1b
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions vm/internal/setup/bugsnag.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,17 @@ func ConfigureBugsnagHandler(server *http.Server) {
}

func ConfigureBugsnagHTTPErrorHandler(err error, c echo.Context) {
if os.Getenv("BUGSNAG_API_KEY") != "" {
if he, ok := err.(*echo.HTTPError); ok {
if he.Code == http.StatusInternalServerError {
// log to container logs
log.Error(err)
// log to Bugsnag
_ = bugsnag.Notify(err, c.Request().Context())
}
} else {
// log to container logs
log.Error(err)
// log to Bugsnag
_ = bugsnag.Notify(err, c.Request().Context())
}
if os.Getenv("BUGSNAG_API_KEY") == "" {
return
}

he, ok := err.(*echo.HTTPError)
if ok && he.Code != http.StatusInternalServerError {
return
}

log.Error(err)
_ = bugsnag.Notify(err, c.Request().Context())
}

func getDockerDesktopVersion() string {
Expand Down

0 comments on commit 288ef1b

Please sign in to comment.