c# - How to access the Request object in a custom exception handler in ServiceStack -


i want register custom exception handler in servicestack. wiki @ https://github.com/servicestack/servicestack/wiki/error-handling says:

this.serviceexceptionhandler = (request, exception) => {     //log exceptions here     ...     //call default exception handler or prepare own custom response     return dtoutils.handleexception(this, request, exception); }; 

but in exception handler request argument not request object, rather service threw exception (at least can tell debugger). casting request ihttprequest fails invalidcast exception. since request/response members of service protected, cannot access request within exception handler.

what access request? in particular, need access content-type , list of accepted languages send headers in request.

from looking @ source, looks request should request dto, if need more that, can create own servicerunner<t>, , irequestcontext well, has contenttype property.

https://github.com/servicestack/servicestack/wiki/error-handling#fine-grain-error-handling-using-the-new-apis-servicerunner

edit, bit more info:

when overwrite handleexception, can return httperror, allow set things headers , responsestatus etc.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -