Last post Mar 08, 2018 02:06 AM by Edward Z
Mar 06, 2018 08:24 AM|Arpan30M|LINK
I am creating a package lib for all the errors in a Webapi service. This library will be used for providing custom responses for BadRequest, BadArgument, ApiVersionsing etc.. related errors. I need help in customizing Apiversion related errors for - ApiVersionUnspecified,
UnsupportedApiVersion, InvalidApiVersion, AmbiguousApiVersion. I have follow this article to include api-versioning for my project - https://www.hanselman.com/blog/ASPNETCoreRESTfulWebAPIVersioningMadeEasy.aspx
I have checked the github wiki for the above package and found that "Depending on the desired behavior, you can extend the DefaultErrorResponseProvider or you can implement your own IErrorResponseProvider from stratch.
To wire up an alternate error response behavior, replace the default provider with your own:"
options => options.ErrorResponses = new MyErrorResponseProvider();
However; I am not quite getting how can I customize the default error responses in MyErrorResponseProvider class. Can somebody please provide me with any example so I can get started with this?
Thanks in advance!
Mar 08, 2018 02:06 AM|Edward Z|LINK
>> I am not quite getting how can I customize the default error responses in MyErrorResponseProvider class
What error did you catch and what response did you want to return?
I think you could refer the DefaultErrorResponseProvider to implement your own