Q:

Redirect to error page when an error occurs in a javascript loaded partial view MVC

I have a project and in this project I have a combobox. In this combobox the user can select to create a new timeroster or edit an existing timeroster.
Based on what is selected a different partial view is loaded inside a div.
function loadTimeRoster() {
    var ID = comboboxTimeRoster.options[comboboxTimeRoster.selectedIndex].value;

    if (ID == 0) {
        url = '/TimeRoster/Create/';
    }
    else {
        url = '/TimeRoster/Edit/?Id=' + ID;
    }

    $('#partial').load(url);
}

If an error occurs in the loaded partial view I would like the user to be redirected to my custom error page with the error code included so I can log it. 
When an error occurs on a normal view I am able to redirect the user to the custom error page because I have set it up in web.config:
<customErrors mode="On" defaultRedirect="Error">
    <error statusCode="404" redirect="Spoorloos"/>
</customErrors>

A:

I first did the javascript way but it was hard to get the error out of it.
That is why I stupped using custom errorpages in web.config and changed the function 'Application_Error' so I manually redirect every error. This also gave me the option to log the exception.
    protected void Application_Error(object sender, EventArgs e)
    {
        Exception exc = Server.GetLastError();

        ExceptionUtility.LogException(exc, "DefaultPage");
        ExceptionUtility.MailException(exc, extraGegevens);

        Response.Redirect("~/Error/Error");
    }

