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() });
public static ErrorResponse CreateErrorResponse(this AuthorizationConfigException ex) { var error = $"{ex.Message}"; return(new ErrorResponse(error, HttpStatusCode.Unauthorized, null)); }