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

Commit

Permalink
refactor: removing switch from the error status verification
Browse files Browse the repository at this point in the history
  • Loading branch information
dmuriel committed Dec 9, 2021
1 parent e9050a3 commit 26caa52
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,12 @@ func (a *App) defaultErrorMiddleware(next Handler) Handler {
}
status := http.StatusInternalServerError
// unpack root err and check for HTTPError
switch {
case errors.Is(err, sql.ErrNoRows):
if errors.Is(err, sql.ErrNoRows) {
status = http.StatusNotFound
fallthrough
default:
var h HTTPError
if errors.As(err, &h) {
status = h.Status
}
}
var h HTTPError
if errors.As(err, &h) {
status = h.Status
}
payload := events.Payload{
"context": c,
Expand Down

0 comments on commit 26caa52

Please sign in to comment.