Quantcast
Channel: Developer to developer
Viewing all articles
Browse latest Browse all 9076

Unexpected error handling. Hides the real error.

$
0
0

We are having an issue right now where when an error is thrown from a controller, it is trying to route the error to an error page that does not exist. In turn this error is handled by our own custom handling with the customErrors web config and logging to our sql server logs.

This is the error that gets logged:

System.InvalidOperationException: The view 'Error' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Category/Error.cshtml
~/Views/Category/Error.vbhtml
~/Views/Shared/Error.cshtml
~/Views/Shared/Error.vbhtml
~/Views/Category/Error.aspx
~/Views/Category/Error.ascx
~/Views/Shared/Error.aspx
~/Views/Shared/Error.ascx

It should not be trying to use this 'Error' page as we have not configured it to do so. This is an issue as this error and not the real error gets logged.

See our config for errors:

Web Config

<customErrors mode="On"><error statusCode="404" redirect="/page-not-found" /><error statusCode="500" redirect="/server-error" /></customErrors><httpErrors errorMode="Custom" existingResponse="PassThrough"><remove statusCode="404" subStatusCode="-1" /><error statusCode="404" path="/page-not-found" responseMode="ExecuteURL" /><remove statusCode="500" subStatusCode="-1" /><error statusCode="500" path="/server-error" responseMode="ExecuteURL" /></httpErrors><!-- Global error handling is turned off so it should be using our own defined error handling --><episerver><applicationSettings globalErrorHandling="Off" httpCacheability="Public" pageValidateTemplate="false" uiShowGlobalizationUserInterface="true" uiUrl="~/EPiServer/CMS/" urlRebaseKind="ToRootRelative" /></episerver>

And our handler for errors to log to SQL

protected void Application_Error(object sender, EventArgs e)
        {
            Exception exception = Server.GetLastError();
            LogManager.GetLogger().Log(Level.Error, "Unhandled error occurred", exception);            
        }

Of course we can turn off custom errors for development, but we need this for better error logging in our production enviornment.

Thanks for any help


Viewing all articles
Browse latest Browse all 9076

Trending Articles