Skip to content

Instantly share code, notes, and snippets.

@soxjke
Created November 17, 2016 22:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soxjke/fe54a06dc8dd82f33f1a6b4bd0e1773d to your computer and use it in GitHub Desktop.
Save soxjke/fe54a06dc8dd82f33f1a6b4bd0e1773d to your computer and use it in GitHub Desktop.
import Foundation
enum ConnectionFailure : ErrorType {
case Error
}
func throwConnectionError() throws -> String {
throw ConnectionFailure.Error
return connect()
}
func connect() -> String {
return "Connection"
}
func test() -> String {
do {
return try throwConnectionError() + "papa"
}
catch let error as ConnectionFailure {
switch (error) {
case .Error: print("mama")
return ("mama")
}
}
catch { return "UFO" }
}
print(test())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment