Skip to content

Instantly share code, notes, and snippets.

@indragiek
Created June 14, 2015 02:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indragiek/dd93cf3a721c3adce64a to your computer and use it in GitHub Desktop.
Save indragiek/dd93cf3a721c3adce64a to your computer and use it in GitHub Desktop.
func crashOnError<T>(f: Void throws -> T) -> T {
do {
return try f()
} catch {
fatalError("Uncaught error")
}
}
enum TestError: ErrorType {
case AnError
}
func throwingFunction() throws {
throw TestError.AnError
}
crashOnError { try throwingFunction() }
@indragiek
Copy link
Author

Scratch that. Here's how to do it the short way: https://twitter.com/myell0w/status/609907058461151232

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment