MVC 5 JQuery Load - Capturing an internal exception

I have a partial view that loads an ObjectResult from an SQL procedure. It uses the built-in EF method.

public virtual ObjectResult<Something_Result> getSomething()
{
    return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<Something_Result>("getSomething");
}

Thus, a common problem is timeouts from the database, and I would like to show this. But I cannot find this in the object of the exception from the Ajax.Load () function. In responseText I only get "{"message":"An error occurred while executing the command definition. See the inner exception for details."}"with status: 500

Is this an easy way to get an internal exception? Here is the exception caused by the Ajax.load () function http://i.imgur.com/ZIrTrMU.jpg And here is the Internal Exception from EF: http://i.imgur.com/LgOhOlB.png

+4
source share
1

catch try , getSomething . , catch, :

if(ex.Number == -2)

if(ex.InnerException != null && ex.InnerException.Number == -2)
 return Json(new { successful = false, Message = "Timeout" });

Json TimeOutException, catch "Timeout Exception"

catch(TimeoutException ex)  
{  return Json(new { successful = false, Message = "Timeout" }); }
+2

All Articles