fix: Handle only 500 errors in ErrorHandler

This commit is contained in:
Prad Nukala 2024-12-29 13:19:21 -05:00
parent bb0e8495d3
commit afc6343c21

View File

@ -5,11 +5,12 @@ import (
"github.com/onsonr/sonr/gateway/context" "github.com/onsonr/sonr/gateway/context"
) )
// AI! Fix this error handler to only return on 500 errors
func ErrorHandler(err error, c echo.Context) { func ErrorHandler(err error, c echo.Context) {
if he, ok := err.(*echo.HTTPError); ok { if he, ok := err.(*echo.HTTPError); ok {
if he.Code == 500 {
// Log the error if needed // Log the error if needed
c.Logger().Errorf("Error: %v", he.Message) c.Logger().Errorf("Error: %v", he.Message)
context.RenderError(c, he) context.RenderError(c, he)
} }
}
} }