#18663: Custom errors should not shorcut HandleErrorAttribute

Work Item: 18663

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2012-07-02 14:52:29 -07:00
parent 455171699a
commit 4ec7cb38ff

View File

@@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Net; using System.Net;
using System.Web; using System.Web;
using System.Web.Mvc; using System.Web.Mvc;
@@ -30,6 +31,9 @@ namespace Orchard.Exceptions.Filters {
} }
public void OnActionExecuted(ActionExecutedContext filterContext) { public void OnActionExecuted(ActionExecutedContext filterContext) {
// don't provide custom errors if the action has some custom code to handle exceptions
if(!filterContext.ActionDescriptor.GetCustomAttributes(typeof(HandleErrorAttribute), false).Any()) {
if (!filterContext.ExceptionHandled && filterContext.Exception != null) { if (!filterContext.ExceptionHandled && filterContext.Exception != null) {
if (_exceptionPolicy.HandleException(this, filterContext.Exception)) { if (_exceptionPolicy.HandleException(this, filterContext.Exception)) {
var shape = _orchardServices.New.ErrorPage(); var shape = _orchardServices.New.ErrorPage();
@@ -61,6 +65,7 @@ namespace Orchard.Exceptions.Filters {
} }
} }
} }
}
if (filterContext.Result is HttpNotFoundResult) { if (filterContext.Result is HttpNotFoundResult) {
var model = _orchardServices.New.NotFound(); var model = _orchardServices.New.NotFound();