Skip to content

Instantly share code, notes, and snippets.

@krzyzanowskim
Created June 23, 2019 00:36
Show Gist options
  • Save krzyzanowskim/a70b8e782ce031518fcbda4f69616b4f to your computer and use it in GitHub Desktop.
Save krzyzanowskim/a70b8e782ce031518fcbda4f69616b4f to your computer and use it in GitHub Desktop.
func XCTAssertThrowsError2<T>(_ expression: () throws -> T, _ message: @autoclosure () -> String = "", file: StaticString = #file, line: UInt = #line, _ errorHandler: (Error) -> Void = { _ in }) {
do {
_ = try expression()
XCTFail(message())
} catch {
errorHandler(error)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment