You've used c.Next() in the error handling middleware, which is logically incorrect. When a panic occurs, the execution halts, and continuing with c.Next() isn't appropriate. Instead, you should use c.Abort(), which is the preferred approach. c.Abort() ensures that next handlers in the chain are not called which effectively stopping further processing.