Exemple #1
0
 private void HandleAjaxError(ExceptionContext context)
 {
     context.Result = new AbpJsonResult
     {
         Data = new AbpMvcAjaxResponse(AbpErrorInfo.ForException(context.Exception))
     };
 }
Exemple #2
0
 public override void OnException(HttpActionExecutedContext context)
 {
     LogHelper.Logger.Error(context.Exception.Message, context.Exception);
     context.Response = context.Request.CreateResponse(
         HttpStatusCode.OK,
         new AbpAjaxResponse(AbpErrorInfo.ForException(context.Exception))
         );
 }
Exemple #3
0
        private void HandleNonAjaxError(ExceptionContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (context.ExceptionHandled || context.IsChildAction)
            {
                return;
            }

            // If custom errors are disabled, we need to let the normal ASP.NET exception handler
            // execute so that the user can see useful debugging information.
            if (!context.HttpContext.IsCustomErrorEnabled) //TODO: To check or not to check this?
            {
                return;
            }

            //TODO: Move this to another class to be able to share!
            var message = context.Exception is UserFriendlyException
                              ? context.Exception.Message
                              : "General exception message here!";

            context.Result = new ViewResult
            {
                ViewName   = View,
                MasterName = Master,
                ViewData   = new ViewDataDictionary <AbpErrorInfo>(AbpErrorInfo.ForException(context.Exception)),
                TempData   = context.Controller.TempData
            };

            context.ExceptionHandled = true;
            context.HttpContext.Response.Clear();
            context.HttpContext.Response.StatusCode = 500;

            // Certain versions of IIS will sometimes use their own error page when
            // they detect a server error. Setting this property indicates that we
            // want it to try to render ASP.NET MVC's error page instead.
            context.HttpContext.Response.TrySkipIisCustomErrors = true;
        }
 /// <summary>
 /// Creates an <see cref="AbpAjaxResponse"/> object with <see cref="Error"/> specified.
 /// <see cref="Success"/> is set as false.
 /// </summary>
 /// <param name="error">Error details</param>
 /// <param name="unAuthorizedRequest">Used to indicate that the current user has no privilege to perform this request</param>
 public AbpAjaxResponse(AbpErrorInfo error, bool unAuthorizedRequest = false)
 {
     Error = error;
     UnAuthorizedRequest = unAuthorizedRequest;
     Success = false;
 }
Exemple #5
0
 /// <summary>
 /// Creates an <see cref="AbpMvcAjaxResponse"/> object with <see cref="AbpAjaxResponse.Error"/> specified.
 /// <see cref="AbpAjaxResponse.Success"/> is set as false.
 /// </summary>
 /// <param name="error">Error details</param>
 /// <param name="unAuthorizedRequest">Used to indicate that the current user has no privilege to perform this request</param>
 public AbpMvcAjaxResponse(AbpErrorInfo error, bool unAuthorizedRequest = false)
     : base(error, unAuthorizedRequest)
 {
 }
Exemple #6
0
 /// <summary>
 /// Creates an <see cref="AbpAjaxResponse"/> object with <see cref="Error"/> specified.
 /// <see cref="Success"/> is set as false.
 /// </summary>
 /// <param name="error">Error details</param>
 /// <param name="unAuthorizedRequest">Used to indicate that the current user has no privilege to perform this request</param>
 public AbpAjaxResponse(AbpErrorInfo error, bool unAuthorizedRequest = false)
 {
     Error = error;
     UnAuthorizedRequest = unAuthorizedRequest;
     Success             = false;
 }