Skip to content

Instantly share code, notes, and snippets.

@toshi0383
Created July 25, 2015 06:21
Show Gist options
  • Save toshi0383/522f0b7da30a4aff8337 to your computer and use it in GitHub Desktop.
Save toshi0383/522f0b7da30a4aff8337 to your computer and use it in GitHub Desktop.
throwsとrethrows。うーんここまでやるかなあ。 #cswift #CodePiece
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