Last active
June 15, 2016 19:10
-
-
Save zhxnlai/169005aa6573d3ab47c10103753fe797 to your computer and use it in GitHub Desktop.
Async Task Error Handling
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 load(path: String) -> ThrowableTask<NSData> { | |
return ThrowableTask { | |
switch path { | |
case "profile.png": | |
return NSData() | |
case "index.html": | |
return NSData() | |
default: | |
throw Error.NotFound | |
} | |
} | |
} | |
expect{try load("profile.png").await()}.notTo(throwError()) | |
expect{try load("index.html").await()}.notTo(throwError()) | |
expect{try load("random.txt").await()}.to(throwError()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment