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

throw new ApiException($"User with id '{userId}' does not exist"); sets status to 500 instead of 4xx #94

Closed HadiSDev closed 3 years ago

HadiSDev commented 3 years ago

For some weird reason the status code is set to 500 when I throw a throw new ApiException($"User with id '{userId}' does not exist"); exception. They default value should be 4xx

{ "isError": true, "type": "https://httpstatuses.com/500", "title": "Internal Server Error", "status": 500, "detail": "User with id 'asasa' does not exist", "instance": "/api/Users/GetUser", "extensions": {} }

HadiSDev commented 3 years ago

I used UseApiProblemDetailsException = true while using custom response mapping. Which you apparently cannot do