I'm working on an ASP.NET MVC application and just getting to error handling. Help me solve the issue of getting the error message back to the user.
I have a controller:
[AcceptVerbs(HttpVerbs.Get)] public ActionResult Show(string callNumber) { ServiceCallService sc = new ServiceCallService(); return View(sc.GetServiceCallByCallNumber("", callNumber)); } a Service:
public ServiceCall GetServiceCallByCallNumber(string custID, string callNumber) { ServiceCall sc = new ServiceCall(); sc = _serviceCallRepository.GetServiceCallByCallNumber(custID, callNumber); return sc; } a Repository:
public ServiceCall GetServiceCallByCallNumber(string custID, string callNumber) { ServiceCall sc = new ServiceCall(); try { LoginToDB(); sc.CallNumber = "123"; } catch (Exception e) { logger.error(Server.GetLastError()); } finally { LogoutFromDB(); } return sc; } Let's say there is a problem in the LoginToDB() method. I am logging the error but how do I get the error message back to the controller and then to the view.
Thanks.