-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from emadhegab/develop
Error Dependency Removal
- Loading branch information
Showing
8 changed files
with
177 additions
and
74 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
// | ||
// CustomError.swift | ||
// MHNetwork | ||
// | ||
// Created by Mohamed Emad Abdalla Hegab on 20.07.18. | ||
// Copyright © 2018 Mohamed Hegab. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum HTTPStatusCodes: Int { | ||
case unspecified = 0 // for testing perpuse | ||
// 100 Informational | ||
case `continue` = 100 | ||
case switchingProtocols | ||
case processing | ||
// 200 Success | ||
case ok = 200 | ||
case created | ||
case accepted | ||
case nonAuthoritativeInformation | ||
case noContent | ||
case resetContent | ||
case partialContent | ||
case multiStatus | ||
case alreadyReported | ||
case imUsed = 226 | ||
// 300 Redirection | ||
case multipleChoices = 300 | ||
case movedPermanently | ||
case found | ||
case seeOther | ||
case notModified | ||
case useProxy | ||
case switchProxy | ||
case temporaryRedirect | ||
case permanentRedirect | ||
// 400 Client Error | ||
case badRequest = 400 | ||
case unauthorized | ||
case paymentRequired | ||
case forbidden | ||
case notFound | ||
case methodNotAllowed | ||
case notAcceptable | ||
case proxyAuthenticationRequired | ||
case requestTimeout | ||
case conflict | ||
case gone | ||
case lengthRequired | ||
case preconditionFailed | ||
case payloadTooLarge | ||
case uriTooLong | ||
case unsupportedMediaType | ||
case rangeNotSatisfiable | ||
case expectationFailed | ||
case imATeapot | ||
case misdirectedRequest = 421 | ||
case unprocessableEntity | ||
case locked | ||
case failedDependency | ||
case upgradeRequired = 426 | ||
case preconditionRequired = 428 | ||
case tooManyRequests | ||
case requestHeaderFieldsTooLarge = 431 | ||
case unavailableForLegalReasons = 451 | ||
// 500 Server Error | ||
case internalServerError = 500 | ||
case notImplemented | ||
case badGateway | ||
case serviceUnavailable | ||
case gatewayTimeout | ||
case httpVersionNotSupported | ||
case variantAlsoNegotiates | ||
case insufficientStorage | ||
case loopDetected | ||
case notExtended = 510 | ||
case networkAuthenticationRequired | ||
|
||
public var description: String { | ||
switch self { | ||
case .badRequest: | ||
return "Bad Request" | ||
case .unauthorized: | ||
return "Unauthorized" | ||
case .forbidden: | ||
return "Forbidden" | ||
case .notFound: | ||
return "Not Found" | ||
case .internalServerError: | ||
return "Internal Server Error" | ||
case .notImplemented: | ||
return "Not implemented" | ||
case .badGateway: | ||
return "Bad Gateway" | ||
case .serviceUnavailable: | ||
return "Service Unavailable" | ||
|
||
default: | ||
return "Error with code: \(self.rawValue)" | ||
} | ||
} | ||
} | ||
|
||
extension HTTPStatusCodes { | ||
public var convertStatusCodeToErrorItem: ErrorItem { | ||
return (self, nil, nil) | ||
} | ||
} |
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
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.