EduardoPires / EquinoxProject

Full ASP.NET Core 6 application with DDD, CQRS and Event Sourcing concepts

Home Page:http://equinoxproject.azurewebsites.net/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Advise on handling Exceptions

gang89 opened this issue · comments

Hi guys,

Thanks for sharing this project with the community. Have benefited a lot from here just by studying and trying out the project structure.

Would like to clarify regarding the handling of exceptions for this project. It seems like any exceptions that are found in the domain layer is not able to be captured by a global exception.

Example:
In one of my domain model constructor - I were to deliberate throw an exception
Screenshot 2019-10-20 at 6 36 28 PM

I would expect it to be caught by a global exception handler such as below and returns an error
Screenshot 2019-10-20 at 6 37 40 PM

However, the API constantly returns a 200 OK success with no error message (probably because I didnt use the domainNotification Bus).

I also tried implementing along with GlobalExceptionFilter / Exception Middleware but to no avail.
It seems like the system exceptions are not surfaced to the API project Exception Handlers.

Have been looking for solutions for a few days now. Hence any advise would be greatly appreciated.

Regards,

commented

@gang89 We try to avoid exceptions for known reasons. You can let validations do all the work and they will publish error notifications