practical-api-guidelines
practical-api-guidelines copied to clipboard
Migrate exception handler to Arcus approach
Migrate exception handler to Arcus approach - https://github.com/arcus-azure/arcus.webapi/issues/14
in the first implementation we are returning the problem+json without external libs / custom middleware. not the more elegant approach.
TODO : validate what is the best approach problem+json is returned for 4XX and 5XX
- 5XX by the generic exception handler
- 400 for invalid model (controller decorated with [ValidateModel])
- 4XX by passing ProblemDetailsError to the ActionResult (this is not an elegant solution but I preferred to limit the usage of external libraries like this https://github.com/khellang/Middleware )
- unmatched routes via UseStatusCodePagesWithReExecute + error controller (e.g. 404)
Just FYI but we are planning to provide this all via Arcus, how it will look like it not defined yet.
I wanted to add to the PR #73 the first basic implementation. When Arcus will be ready, we will migrate.