Skip to content

Instantly share code, notes, and snippets.

@DominicFinn
Created July 19, 2013 13:18
Show Gist options
  • Select an option

  • Save DominicFinn/6039049 to your computer and use it in GitHub Desktop.

Select an option

Save DominicFinn/6039049 to your computer and use it in GitHub Desktop.
Error Controller for Pete
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