Skip to content

Commit

Permalink
fixes potential recursive error wrapping within error_handler, especi…
Browse files Browse the repository at this point in the history
…ally in combination with echoHTTPErrors
  • Loading branch information
majodev committed Sep 13, 2022
1 parent 6eddec0 commit 4cf20ba
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions internal/api/router/error_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ func HTTPErrorHandlerWithConfig(config HTTPErrorHandlerConfig) echo.HTTPErrorHan

if code == http.StatusInternalServerError && config.HideInternalServerErrorDetails {
if httpError.Internal == nil {
httpError.Internal = fmt.Errorf("Internal Error: %w", httpError)
//nolint:errorlint
httpError.Internal = fmt.Errorf("Internal Error: %s", httpError)
}

httpError.Title = swag.String(http.StatusText(http.StatusInternalServerError))
Expand All @@ -54,7 +55,8 @@ func HTTPErrorHandlerWithConfig(config HTTPErrorHandlerConfig) echo.HTTPErrorHan

if code == http.StatusInternalServerError && config.HideInternalServerErrorDetails {
if httpValidationError.Internal == nil {
httpValidationError.Internal = fmt.Errorf("Internal Error: %w", httpValidationError)
//nolint:errorlint
httpValidationError.Internal = fmt.Errorf("Internal Error: %s", httpValidationError)
}

httpValidationError.Title = swag.String(http.StatusText(http.StatusInternalServerError))
Expand All @@ -64,7 +66,8 @@ func HTTPErrorHandlerWithConfig(config HTTPErrorHandlerConfig) echo.HTTPErrorHan

if code == http.StatusInternalServerError && config.HideInternalServerErrorDetails {
if echoHTTPError.Internal == nil {
echoHTTPError.Internal = fmt.Errorf("Internal Error: %w", echoHTTPError)
//nolint:errorlint
echoHTTPError.Internal = fmt.Errorf("Internal Error: %s", echoHTTPError)
}

he = &httperrors.HTTPError{
Expand Down

0 comments on commit 4cf20ba

Please sign in to comment.