Created
March 27, 2017 16:42
-
-
Save JohnSundell/4f12e289298e48b2a0fdcee17188256f to your computer and use it in GitHub Desktop.
Code sample #3 from https://medium.com/@johnsundell/providing-a-unified-swift-error-api-3642cd3173f0
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
func perform<T>(_ expression: @autoclosure () throws -> T, | |
orThrow error: Error) throws -> T { | |
do { | |
return try expression() | |
} catch { | |
throw error | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment