Advertisement
Guest User

Untitled

a guest
Aug 28th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. import Cocoa
  2.  
  3. var statusCode: Int = -1
  4. var errorString: String = "The request failed with the error:"
  5. switch statusCode {
  6. case 100, 101:
  7. errorString += " Informational, 1xx."
  8.  
  9. case 204:
  10. errorString += " Successful, but no content, 204"
  11.  
  12. case 300...307:
  13. errorString += " Redirection, 3xx"
  14.  
  15. case 400...417:
  16. errorString += " Client error, 4xx"
  17.  
  18. case 500...505:
  19. errorString += " Server error, 5xx"
  20.  
  21. case let unknownCode where (unknownCode >= 200 && unknownCode < 300)
  22. || unknownCode > 505:
  23. errorString = "\(unknownCode) is not a known error code."
  24.  
  25. default:
  26. errorString = "Unexpected error encountered. Status Code: \(statusCode)"
  27. }
  28.  
  29. print(errorString)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement