Skip to content

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.

@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
@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.

2 participants