Created
May 5, 2019 04:36
-
-
Save shishirthedev/351473dd5cff03dc5dfe49ce5c1910c6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import UIKit | |
class ErrorHandler { | |
private init(){} | |
static var view: NetworkViewProtocol? | |
static func handleError(httpSatusCode: Int?, error: Error?){ | |
if let httpCode = httpSatusCode{ | |
switch httpCode{ | |
case NOT_FOUND: | |
view?.onServerError(errorMSG: "NOT FOUND") | |
break | |
case UNAUTHORIZED: | |
view?.onUnauthorized(unAuthorizedMSG: "UNAUTHORIZED USER") | |
break | |
case INTERNEL_SERVER_ERROR: | |
view?.onServerError(errorMSG: "INTERNAL SERVER ERROR") | |
break | |
default: | |
print("FAILED") | |
} | |
}else if let error = error as NSError?{ | |
if error == NSError.NO_INTERNET{ | |
view?.networkUnavailable() | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment