Skip to content

Instantly share code, notes, and snippets.

@Mintri1199
Created May 14, 2019 07:18
Show Gist options
  • Save Mintri1199/b8cfeaa01b8c8aa56dcfe82de536ea6c to your computer and use it in GitHub Desktop.
Save Mintri1199/b8cfeaa01b8c8aa56dcfe82de536ea6c to your computer and use it in GitHub Desktop.
fileprivate func newHandleNetworkResponse(_ response: HTTPURLResponse) -> Result<String, NetworkReponse> {
switch response.statusCode {
case 200...299: return Result.success("Success")
case 401...500: return Result.failure(.authenticationError)
case 501...599: return Result.failure(.badRequest)
case 600: return Result.failure(.outdated)
default: return Result.failure(.failed)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment