Skip to content

Added a optional config variable to disable centralized error handler in recovery middleware - #2410

Merged
aldas merged 5 commits into
labstack:masterfrom
Omkar-C:master
Feb 24, 2023
Merged

aldas merged 5 commits into
labstack:masterfrom
Omkar-C:master

Conversation

@Omkar-C

@Omkar-C Omkar-C commented Feb 23, 2023 •

Copy link
Copy Markdown
Contributor

Recovery Middleware calls the centralized Error Handler. This is a change to have a optional config variable to disable centralized error handler in recovery. If the centrailzed Error Handler is disabled, panic error caught, will be returned to upstream middleware.

@Omkar-C

Omkar-C commented Feb 23, 2023

Copy link
Copy Markdown
Contributor Author

Should I pass back the error with closure, so upstream middlewares can handle ?

@Omkar-C

Omkar-C commented Feb 23, 2023

Copy link
Copy Markdown
Contributor Author

Should I pass back the error with closure, so upstream middlewares can handle ?

I have returned back the error, seems like that should be the ideal behavior, also added corrected tests

Comment thread middleware/recover.go Outdated
Comment thread middleware/recover_test.go Outdated
Comment thread middleware/recover.go
…r is only returned back if centralized error handler is disabled, improved test cases
@Omkar-C
Omkar-C requested a review from aldas February 24, 2023 05:57
@codecov

codecov Bot commented Feb 24, 2023 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.85%. Comparing base (47844c9) to head (e368ae0).
⚠️ Report is 186 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2410   +/-   ##
=======================================
  Coverage   92.84%   92.85%           
=======================================
  Files          39       39           
  Lines        4503     4507    +4     
=======================================
+ Hits         4181     4185    +4     
  Misses        234      234           
  Partials       88       88           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Omkar-C Omkar-C changed the title Added a optional config variable to disable centralized error handler in recovery Added a optional config variable to disable centralized error handler in recovery middleware Feb 24, 2023

@aldas aldas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@aldas

aldas commented Feb 24, 2023

Copy link
Copy Markdown
Contributor

For history sake - not returning error by default bothers me as it would be more correct behavior. But this would make middleware behave completely different as it has done since 2015. These simple things can be problematic as it changes how already existing application middleware chain work. Probably 98% time this is not an issue - but for some it could be.

life is about making compromises.

p.s. just looked my v5 branch and there I already have made so that c.Errror is not used anymore and we return that recovered "error"

@aldas
aldas merged commit 1e575b7 into labstack:master Feb 24, 2023
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