DavidAJohn / FotoStorioMicroservices

.NET application built using a microservice architecture with Docker containers. Includes a Blazor WebAssembly e-commerce store with Stripe Elements payment integration.
23 stars 4 forks source link

Exception Middleware #12

Closed DavidAJohn closed 10 months ago

DavidAJohn commented 11 months ago

There are several Services projects that have controllers which contain try...catch logic. It makes me feel a little uneasy seeing 500 errors being returned in so many of the catch sections.

I'd like to get rid of that repetitive code and use some form of exception middleware instead, which would make the controllers simpler and centralise exception handling and logging.

Something like Jason Watmore's solution would be ideal: https://jasonwatmore.com/post/2022/01/17/net-6-global-error-handler-tutorial-with-example

DavidAJohn commented 10 months ago

I've now added exception middleware to the Products, Orders and Inventory services.

There's not a great deal to be gained from adding it to the other services, so I'll close this issue.