I'm trying to use the ServiceExceptionHandler
on my Serivce which extends RestServiceBase<TViewModel>
I can use the AppHost.ServiceExceptionHandler
, that's working fine. I need the user info from the HttpRequest
, thats not available at AppHost level.
So I'm trying to use the ServiceExceptionHandler
on Service level. Though I set the delegate on service ctor
, it's null
when exception thrown on OnGet
method
public class StudentService : RestServiceBase<Student>
{
public StudentService()
{
ServiceExceptionHandler = (request, exception) =>
{
logger.Error(string.Format("{0} - {1}
Request : {2}
", HttpRequest.UserName(), exception.Message, request.Dump()), exception);
var errors = new ValidationErrorField[] { new ValidationErrorField("System Error", "TODO", "System Error") };
return DtoUtils.CreateErrorResponse("System Error", "System Error", errors);
};
}
}
I'm not sure of what is the issue with this code. Any help will be appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…