Created
October 19, 2019 16:04
-
-
Save isaac-weisberg/4511dd68192e0937dcea2f91d99cb251 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
authError = forecast | |
.map { result -> AuthErrorModelRepresentable? in | |
switch result.lastResult { | |
case .none, .success: | |
return nil | |
case .failure(let reason): | |
switch reason { | |
case .downloadError(let reason): | |
switch reason { | |
case .download(let reason): | |
switch reason { | |
case .unauthorized: | |
return AuthErrorFromMain() | |
case .networkError, .invalidResponseType, .noData, .unexpectedStatusCode: | |
return nil | |
} | |
case .parsing: | |
return nil | |
} | |
case .temperatureInvalid: | |
return nil | |
} | |
} | |
} | |
.filter { $0 != nil }.map { $0! } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment