I've edited a patched a pipeline using the following bit of code.
<sitecore>
<pipelines>
<mvc.exception>
<processor type="Sitecore.Mvc.Pipelines.MvcEvents.Exception.ShowAspNetErrorMessage, Sitecore.Mvc">
<patch:attribute name="type">ProjectName.PublicSite.Web.App_Pipelines.ExceptionHandler.ExceptionHandler, ProjectName.PublicSite.Web</patch:attribute>
</processor>
</mvc.exception>
In addition, I've created the following class to handle things that fall in the mvc.exception
pipeline.
namespace ProjectName.PublicSite.Web.App_Pipelines.ExceptionHandler
{
using Sitecore.Mvc.Pipelines.MvcEvents.Exception;
using Sitecore.Diagnostics;
using System.Configuration;
using System.Web.Configuration;
public class ExceptionHandler : ExceptionProcessor
{
public override void Process(ExceptionArgs args)
{
var context = args.ExceptionContext;
var httpContext = context.HttpContext;
var exception = context.Exception;
if (context.ExceptionHandled || httpContext == null || exception == null || !httpContext.IsCustomErrorEnabled)
{
return;
}
else
{
Log.Error(exception.Message, exception);
httpContext.Server.ClearError();
string redirect = "/error";
httpContext.Response.Redirect(redirect, false);
}
}
}
}
The problem that I'm having is that this only handles certain exceptions that can occur, as detailed here and here. I'd like to handle other exceptions that can arise. I've tried adding the following code to the Global.asax.cs file.
protected void Application_Error (object sender, EventArgs e)
{
Sitecore.Diagnostics.Log.Error("This is an error.", sender);
}
However, I'm not able to get it to hit when I throw an exception in the code. My overall goal is to be able to log any exceptions that may occur in the Sitecore logs.