Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(DefaultHTTPErrorHandler): return error message when message is an error #2456

Merged
merged 4 commits into from May 29, 2023

Conversation

gnuletik
Copy link
Contributor

The current behavior when returning a go error from a echo handler like this:

return echo.NewHTTPError(status.BadRequest, errors.New("error in httperror"))

Is that echo returns an empty JSON object {}.

See the failing test result, without the fix:

    echo_test.go:1356:
        	Error Trace:	/~/echo/echo_test.go:1356
        	Error:      	Not equal:
        	            	expected: "{\"message\":\"error in httperror\"}\n"
        	            	actual  : "{}\n"

        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1,2 +1,2 @@
        	            	-{"message":"error in httperror"}
        	            	+{}

        	Test:       	TestDefaultHTTPErrorHandler

@codecov
Copy link

codecov bot commented May 26, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (8e425c0) 92.85% compared to head (e7e0db9) 92.86%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2456   +/-   ##
=======================================
  Coverage   92.85%   92.86%           
=======================================
  Files          39       39           
  Lines        4563     4568    +5     
=======================================
+ Hits         4237     4242    +5     
  Misses        237      237           
  Partials       89       89           
Impacted Files Coverage Δ
echo.go 95.52% <100.00%> (+0.05%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

echo.go Show resolved Hide resolved
echo_test.go Outdated Show resolved Hide resolved
@gnuletik gnuletik requested a review from aldas May 29, 2023 12:37
Copy link
Contributor

@aldas aldas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aldas aldas merged commit fbfe216 into labstack:master May 29, 2023
13 checks passed
@aldas
Copy link
Contributor

aldas commented May 29, 2023

Thank @gnuletik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants