Created
July 25, 2015 06:21
-
-
Save toshi0383/522f0b7da30a4aff8337 to your computer and use it in GitHub Desktop.
throwsとrethrows。うーんここまでやるかなあ。 #cswift #CodePiece
This file contains hidden or 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
func executeRethrows(f:() throws ->()) rethrows { | |
do{try f()}catch{print(error)} | |
} | |
func execute(f:() throws ->()) { | |
do{try f()}catch{print(error)} | |
} | |
enum MyError:ErrorType { | |
case A, B | |
} | |
execute{ | |
throw MyError.A | |
} | |
try executeRethrows { | |
throw MyError.A | |
} | |
executeRethrows { | |
print(1) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment