AutoWrapper icon indicating copy to clipboard operation
AutoWrapper copied to clipboard

Custom scheme for runtime called exceptions

Open Dubzer opened this issue 4 years ago • 1 comments

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?

Dubzer avatar Jan 01 '21 23:01 Dubzer

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

proudmonkey avatar Jan 19 '21 16:01 proudmonkey