Custom Error Handling

This commit is contained in:
Gary Sharp
2013-11-11 17:04:04 +11:00
parent a63041abf2
commit 1cbbf1dde4
12 changed files with 296 additions and 49 deletions
+2 -23
View File
@@ -1,6 +1,7 @@
using Disco.Data.Repository;
using Disco.Services.Authorization;
using Disco.Services.Users;
using Disco.Services.Web;
using System;
using System.Configuration;
using System.Diagnostics;
@@ -214,29 +215,7 @@ namespace Disco.Web
#region Global Error Logging
void DiscoApplication_Error(object sender, EventArgs e)
{
try
{
var ex = Server.GetLastError();
if (ex is AccessDeniedException)
{
var accessDeniedException = (AccessDeniedException)ex;
var resource = accessDeniedException.Resource;
var httpContext = HttpContext.Current;
if (httpContext != null && httpContext.Request != null)
resource = string.Format("{0} [{1}]", resource, httpContext.Request.RawUrl);
AuthorizationLog.LogAccessDenied(UserService.CurrentUserId ?? "[Anonymous]", resource, accessDeniedException.Message);
}
else
{
Disco.Services.Logging.SystemLog.LogException("Global Application Exception Caught", ex);
}
}
catch (Exception)
{
// Ignore all logging errors
}
this.HandleException();
}
#endregion
}