Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Cocoa
- var statusCode: Int = -1
- var errorString: String = "The request failed with the error:"
- switch statusCode {
- case 100, 101:
- errorString += " Informational, 1xx."
- case 204:
- errorString += " Successful, but no content, 204"
- case 300...307:
- errorString += " Redirection, 3xx"
- case 400...417:
- errorString += " Client error, 4xx"
- case 500...505:
- errorString += " Server error, 5xx"
- case let unknownCode where (unknownCode >= 200 && unknownCode < 300)
- || unknownCode > 505:
- errorString = "\(unknownCode) is not a known error code."
- default:
- errorString = "Unexpected error encountered. Status Code: \(statusCode)"
- }
- print(errorString)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement