HttpServer.Server.DisplayErrorPage C# (CSharp) Method

DisplayErrorPage() protected method

An error have occurred and we need to send a result pack to the client
Invoke base class (Server) to send the contents of IHttpContext.Response.
protected DisplayErrorPage ( IHttpContext context, Exception exception ) : void
context IHttpContext The context.
exception System.Exception The exception.
return void
        protected virtual void DisplayErrorPage(IHttpContext context, Exception exception)
        {
            var httpException = exception as HttpException;
            if (httpException != null)
            {
                context.Response.Reason = httpException.Code.ToString();
                context.Response.Status = httpException.Code;
            }
            else
            {
                context.Response.Reason = "Internal Server Error";
                context.Response.Status = HttpStatusCode.InternalServerError;
            }


            var args = new ErrorPageEventArgs(context) {Exception = exception};
            ErrorPageRequested(this, args);

            var writer = HttpFactory.Current.Get<ResponseWriter>();
            if (args.IsHandled)
                writer.Send(context, context.Response);
            else
            {
                writer.SendErrorPage(context, context.Response, exception);
                args.IsHandled = true;
            }
        }