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() });