Created
November 17, 2016 22:22
-
-
Save soxjke/fe54a06dc8dd82f33f1a6b4bd0e1773d to your computer and use it in GitHub Desktop.
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
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