Created
July 19, 2013 13:18
-
-
Save DominicFinn/6039049 to your computer and use it in GitHub Desktop.
Error Controller for Pete
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public sealed class ErrorController : Controller | |
| { | |
| readonly IResponse response; | |
| public ErrorController(IResponse response) | |
| { | |
| this.response = response; | |
| } | |
| public ActionResult Error(HttpStatusCode statusCode, Exception exception) | |
| { | |
| var resource = new ErrorResource(statusCode, exception); | |
| response.StatusCode = (int)statusCode; | |
| return View("DebugError", resource); | |
| } | |
| /// <summary> | |
| /// Here to test the live exception handling mechanism | |
| /// </summary> | |
| /// <returns></returns> | |
| [RequiresAuthorization] | |
| public ActionResult CreateException() | |
| { | |
| throw new ApplicationException("Test exception", new ApplicationException("Inner Exception")); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment