Skip to content

Instantly share code, notes, and snippets.

@alexbeletsky
Created September 19, 2011 11:36
Show Gist options
  • Save alexbeletsky/1226336 to your computer and use it in GitHub Desktop.
Save alexbeletsky/1226336 to your computer and use it in GitHub Desktop.
public class Attribute : ActionFilterAttribute {
public override void OnActionExecuted(ActionExecutedContext filterContext) {
base.OnActionExecuted(filterContext);
if (!filterContext.ExceptionHandled) {
var exception = filterContext.Exception;
if (exception is CustomException) {
filterContext.Controller.ViewData.ModelState.Add(String.Empty, Resource.CustomExceptionMessage);
}
else if (excetion is Exception) {
filterContext.Controller.ViewData.ModelState.Add(String.Empty, Resource.GenericExceptionMessage);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment