Given a method signature like this:
func foo(
operation: @escaping () throws(E) -> Void,
handler: @escaping (_ error: E) -> Void
)
is there a way to make the call site see the concrete Error type when calling this? The compiler makes it any Error inside the handler closure.
func foo
operation: @escaping () throws(E) -> Void,
handler: @escaping (_ error: E) -> Void
)
is there a way to make the call site see the concrete Error type when calling this? The compiler makes it any Error inside the handler closure.
Comments
`struct E: Error { }`
, there are ways to handle this. They are not good ways, but they are type-safe.
foo { () throws(E) in
throw .init()
} handler: { error in }
foo { () throws(_) in
throw E()
} handler: { (error: E) in }