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.
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
trykeyword at the use site.