We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
As of mockolo 2.1.1, rethrows method is not supported. The following mock produces compile error:
"error: call can throw, but the error is not handled; a function declared 'rethrows' may only throw if its parameter does"
/// @mockable protocol ThrowableProtocol { func foo(action: () throws -> Int) rethrows } // ----- mock ----- class ThrowableProtocolMock: ThrowableProtocol { init() { } private(set) var fooCallCount = 0 var fooHandler: ((() throws -> Int) throws -> ())? func foo(action: () throws -> Int) rethrows { fooCallCount += 1 if let fooHandler = fooHandler { try fooHandler(action) } } }
This is because rethrows only become throwable when parameter of the method has try keyword at the use site.
try
The text was updated successfully, but these errors were encountered:
protocol P { func f(arg: () throws -> Void) rethrows } struct S: P { var fHandler: (() throws(any Error) -> Void) throws(any Error) -> Void = { _ in } func f<E: Error>(arg: () throws(E) -> Void) throws(E) { do { try fHandler(arg) } catch { throw error as! E } } }
typed throws can solve this problem
Sorry, something went wrong.
No branches or pull requests
As of mockolo 2.1.1, rethrows method is not supported. The following mock produces compile error:
"error: call can throw, but the error is not handled; a function declared 'rethrows' may only throw if its parameter does"
This is because rethrows only become throwable when parameter of the method has
try
keyword at the use site.The text was updated successfully, but these errors were encountered: