Skip to content

Commit

Permalink
fix: update recoverer middleware to properly handle panics
Browse files Browse the repository at this point in the history
Refactor the recoverer middleware to correctly handle panics and prevent
unnecessary error messages from being logged. Update the condition to check
for the presence of a panic before processing it.
  • Loading branch information
Keloran committed May 13, 2024
1 parent 6af9841 commit ff2179c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion middleware/recoverer.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import (
func Recoverer(next http.Handler) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
defer func() {
if rvr := recover(); rvr != nil && rvr != http.ErrAbortHandler {
rvr := recover()
if rvr != nil && rvr != http.ErrAbortHandler {

logEntry := GetLogEntry(r)
if logEntry != nil {
Expand Down

0 comments on commit ff2179c

Please sign in to comment.