private void OnRequest(object sender, RequestEventArgs e)
{
_server = this;
Exception exception;
try
{
ProcessingResult result = HandleRequest(e);
if (result != ProcessingResult.Continue)
return;
exception = null;
}
catch (HttpException err)
{
_logger.Error("Got an HTTP exception.", err);
e.Response.Status = err.Code;
e.Response.Reason = err.Message;
exception = err;
}
catch (Exception err)
{
_logger.Error("Got an unhandled exception.", err);
exception = err;
e.Response.Status = HttpStatusCode.InternalServerError;
e.Response.Reason = "Failed to process request.";
}
if (exception == null)
{
e.Response.Status = HttpStatusCode.NotFound;
e.Response.Reason = "Requested resource is not found. Sorry ;(";
exception = new HttpException(HttpStatusCode.NotFound, "Failed to find uri " + e.Request.Uri);
}
DisplayErrorPage(e.Context, exception);
e.IsHandled = true;
}