예제 #1
0
        public ErrorResponse(Exception exception, ErrorHandlingSettings settings)
        {
            ErrorCode            = "-1";
            Type                 = exception.GetType().Name;
            HumanReadableMessage = "Server error occured";

            if (settings.DeveloperDetails)
            {
                DeveloperDetails = new DeveloperDetails(exception);
            }

            IsCustom = false;
        }
예제 #2
0
        public ErrorResponse(CustomException exception, ErrorHandlingSettings settings)
        {
            ErrorCode            = exception.ErrorCode;
            Type                 = exception.GetType().Name;
            HumanReadableMessage = exception.HumanReadableMessage;

            if (settings.DeveloperDetails)
            {
                DeveloperDetails = new DeveloperDetails(exception);
            }

            IsCustom = true;
        }
예제 #3
0
 // ReSharper disable once UnusedMember.Global - it's called by reflection
 public async Task Invoke(HttpContext context, ErrorHandlingSettings settings)
 {
     try
     {
         await next(context);
     }
     catch (CustomException exception)
     {
         await HandleExceptionAsync(
             context : context,
             httpStatusCode : _customHttpStatusCode,
             errorResponse : new ErrorResponse(exception, settings)
             );
     }
     catch (Exception exception)
     {
         await HandleExceptionAsync(
             context : context,
             httpStatusCode : (int)HttpStatusCode.InternalServerError,
             errorResponse : new ErrorResponse(exception, settings)
             );
     }
 }