Jan 04, 2014, 2:30 PM
[CLOSED] Exception Handling - Throwing Exceptions from Controller, catching them in generic handler
Hi,
My requirement is very basic, I want to throw an exception from controller and I would like to catch the exception in generic handler.\
Setup of generic handler
Requirement:
I just want to set an exception in the controller and throw it from the action method, then I wan to get hold of it in generic handler and show the exception message.
I think I am missing something very obvious here, please guide.
Cheers,
Avinash
My requirement is very basic, I want to throw an exception from controller and I would like to catch the exception in generic handler.\
Setup of generic handler
@Html.X().ResourceManager(ViewBag.ManagerConfig as MvcResourceManagerConfig).Listeners(l => l.AjaxRequestException.Fn = "genericHandle")
Generic Handler, sitting in script var globalHandle =
function (response, result, el, eventType, action, extraParams, o) {
}
Following is how we throw the exceptioncatch(FaultException<T> fault)
{
System.Net.Http.HttpResponseMessage message =
new System.Net.Http.HttpResponseMessage();
message.ReasonPhrase = fault.Message;
message.Content = new System.Net.Http.StringContent(fault.Message);
System.Web.Http.HttpResponseException ex =
new System.Web.Http.HttpResponseException(message);
throw ex;
}
My problem is no matter how I throw exception, I never get the exception-message that I assigned in the controller. I have searched whole graph of response and rest of the parameters but didn't find my message anywhere.Requirement:
I just want to set an exception in the controller and throw it from the action method, then I wan to get hold of it in generic handler and show the exception message.
I think I am missing something very obvious here, please guide.
Cheers,
Avinash
Last edited by Daniil; Jan 10, 2014 at 10:44 AM.
Reason: [CLOSED]