public class GlobalExceptionHandler : ExceptionHandler { public override void Handle(ExceptionHandlerContext context) { context.Result = new NiceInternalServerExceptionResponse("The current operation could not be completed sucessfully.); } }
When calling this Get action:
[HttpGet] public async Task<IHttpActionResult> Get() { Convert.ToInt16("this causes an exception state"); var data = await service.Get(); return Ok(data); }
An exception occurs ... and my global exc handler starts.
When my user response is returned to the client, my violinist always says:
Result: 200
I could also change return Ok(data); on return NotFound();
This will not change anything in the result status code.
How can I rewrite / intercept the creation of the http status and return my own 500 status code?
On my web client, I need to show a nice dialog with an error message id id log + ONLY when returning the status of the code.
source share