proudmonkey / AutoWrapper

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

Custom scheme for runtime called exceptions #93

Open Dubzer opened 3 years ago

Dubzer commented 3 years ago

Hi. I created my own API response schema and I also would like to create schema for exceptions. According to the readme, I can create model and then pass it to the ApiException constructor. But it wouldn't work, for example, with unhandled exceptions that were thrown while controller was executing:

    [HttpGet]
    public ApiResponse AnUnavoidableMistake()
    {
        int.Parse("This will cause an exception");

        return new ApiResponse("It's a miracle we survived!");
    }

This code will return ApiException JSON. So is it possible to replace it with my own error schema?

proudmonkey commented 3 years ago

Hello Dubzer - At the moment, AutoWrapper doesn't support this. All unhandled exceptions will be defaulted to either ApiException or ApiProblemDetailException.