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

Move ErrorHandlerMiddleware down next to HandlerInvocationMiddleware, and ensure exceptions are logged #1023

Merged
merged 4 commits into from
Jun 9, 2022

Conversation

gkinsman
Copy link
Contributor

@gkinsman gkinsman commented Jun 8, 2022

This PR moves the ErrorHandlerMiddleware next to the HandlerInvocationMiddleware, so that the first thing that happens after executing user code is handling an exception if one is thrown, and adding it to the HandleMessageContext via SetException.

Then, it adds the HandledException property to the log context so that the error is visible to users. This should have been happening before but the test was lying to us, as it had a bug in it:
image

@gkinsman gkinsman requested a review from a team as a code owner June 8, 2022 21:08
@gkinsman gkinsman requested a review from slang25 June 8, 2022 21:08
@codecov
Copy link

codecov bot commented Jun 8, 2022

Codecov Report

Merging #1023 (22b521d) into main (5bff12e) will increase coverage by 0.12%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1023      +/-   ##
==========================================
+ Coverage   84.92%   85.04%   +0.12%     
==========================================
  Files         135      135              
  Lines        3290     3290              
==========================================
+ Hits         2794     2798       +4     
+ Misses        496      492       -4     
Flag Coverage Δ
linux 85.04% <100.00%> (+0.12%) ⬆️
macos 51.85% <100.00%> (+0.09%) ⬆️
windows 51.75% <100.00%> (+0.28%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...eware/Handle/HandlerMiddlewareBuilderExtensions.cs 100.00% <100.00%> (ø)
.../Messaging/Middleware/Logging/LoggingMiddleware.cs 100.00% <100.00%> (ø)
...ng/Middleware/ExactlyOnce/ExactlyOnceMiddleware.cs 92.59% <0.00%> (+14.81%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5bff12e...22b521d. Read the comment docs.

…in default setup so that it handles errors as a first priority.

LoggingMiddleware assumes a handled exception is available in the context, as should others, instead of handling and rethrowing themselves.
@gkinsman gkinsman changed the title Add HandleMessageContext.HandledException to log context Move ErrorHandlerMiddleware down next to HandlerInvocationMiddleware, and ensure exceptions are logged Jun 8, 2022
@gkinsman gkinsman merged commit a6aaca6 into justeattakeaway:main Jun 9, 2022
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