Skip to content

Instantly share code, notes, and snippets.

@isaac-weisberg
Created October 19, 2019 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaac-weisberg/4511dd68192e0937dcea2f91d99cb251 to your computer and use it in GitHub Desktop.
Save isaac-weisberg/4511dd68192e0937dcea2f91d99cb251 to your computer and use it in GitHub Desktop.
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