コード例 #1
0
        private void HandleError(RewriteContext context)
        {
            // Return the status code.
            ContextFacade.SetStatusCode((int)context.StatusCode);

            // Get the error handler if there is one.
            IRewriteErrorHandler handler = _configuration.ErrorHandlers[(int)context.StatusCode] as IRewriteErrorHandler;

            if (handler != null)
            {
                try
                {
                    _configuration.Logger.Debug(MessageProvider.FormatString(Message.CallingErrorHandler));

                    // Execute the error handler.
                    ContextFacade.HandleError(handler);
                }
                catch (HttpException)
                {
                    throw;
                }
                catch (Exception exc)
                {
                    _configuration.Logger.Fatal(exc.Message, exc);
                    throw new HttpException(
                              (int)HttpStatusCode.InternalServerError, HttpStatusCode.InternalServerError.ToString());
                }
            }
            else
            {
                throw new HttpException((int)context.StatusCode, context.StatusCode.ToString());
            }
        }