Created
September 12, 2016 15:11
-
-
Save anonymous/7c90ebac7615ef0df76b644a86967850 to your computer and use it in GitHub Desktop.
OriginalHandler
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
enum Error1: ErrorType { | |
case Error1_1 | |
case Error1_2 | |
} | |
enum Error2: ErrorType { | |
case Error2_1 | |
case Error2_2 | |
} | |
func throwError1() throws -> String { | |
throw Error1.Error1_1 | |
return String() | |
} | |
func throwError2() throws -> String { | |
throw Error2.Error2_1 | |
return String() | |
} | |
do { | |
try throwError1() | |
try throwError2() | |
} | |
catch let error as Error1 { | |
switch error { | |
case .Error1_1: print(error) | |
case .Error1_2: print(error) | |
} | |
} | |
catch let error as Error2 { | |
switch error { | |
case .Error2_1: print(error) | |
case .Error2_2: print(error) | |
} | |
} | |
catch let error { | |
print(error) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment