示例#1
0
 private static ErrorResponse ExtractErrorResponseFromContext(ExceptionContext context)
 {
     return(context.Exception switch
     {
         AutoMapperMappingException mappingException => mappingException.CreateErrorResponse(),
         DomainException domainException => domainException.CreateErrorResponse(),
         BusinessException businessException => businessException.CreateErrorResponse(),
         AuthorizationConfigException authorizationConfigException => authorizationConfigException.CreateErrorResponse(),
         UnauthorizedAccessException unauthorizedAccessException => unauthorizedAccessException.CreateErrorResponse(),
         _ => context.Exception.CreateErrorResponse()
     });
示例#2
0
        public static ErrorResponse CreateErrorResponse(this AuthorizationConfigException ex)
        {
            var error = $"{ex.Message}";

            return(new ErrorResponse(error, HttpStatusCode.Unauthorized, null));
        }