practical-api-guidelines icon indicating copy to clipboard operation
practical-api-guidelines copied to clipboard

Migrate exception handler to Arcus approach

Open tomkerkhove opened this issue 7 years ago • 4 comments

Migrate exception handler to Arcus approach - https://github.com/arcus-azure/arcus.webapi/issues/14

tomkerkhove avatar Oct 08 '18 16:10 tomkerkhove

in the first implementation we are returning the problem+json without external libs / custom middleware. not the more elegant approach.

MassimoC avatar Jan 14 '19 15:01 MassimoC

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)

MassimoC avatar Jan 14 '19 17:01 MassimoC

Just FYI but we are planning to provide this all via Arcus, how it will look like it not defined yet.

tomkerkhove avatar Jan 14 '19 17:01 tomkerkhove

I wanted to add to the PR #73 the first basic implementation. When Arcus will be ready, we will migrate.

MassimoC avatar Jan 14 '19 17:01 MassimoC