proudmonkey / AutoWrapper

A simple, yet customizable global exception handler and Http response wrapper for ASP.NET Core APIs.
MIT License
679 stars 82 forks source link

Fix inconsistencies in wrapping responses #123

Closed TIPConsulting closed 2 years ago

TIPConsulting commented 2 years ago

Some exceptions have special casing for http status codes, however the codes were not being set consistently. AutoWrapperBase has a branch on DisableProblemDetailsException. If true, certain exceptions would get special status codes (ex UnauthorizedAccessException=401) on the response. If false, the status modifier was skipped and responses were sent with a basic 500 code.

This has been resolved. In the future, the logic should be extracted so response codes are guaranteed to be sync'd for ApiProblemDetailsHandler.HandleProblemDetailsAsync and ApiRequestHandler.HandleExceptionAsync

Also added a special exception case NotImplementedException=501. This is helpful for auto-scaffolded APIs

Also fixed a bug that made ShowIsErrorFlagForSuccessfulResponse=true a NOP