Not really: you could store a E
somewhere else and throw that stored E
instead. For instance:
var storedError: (any Error)?
func f<E: Error>(body: () throws(E) -> ()) throws(E) {
if let e = storedError as? E {
throw e // and never call body()
}
try body()
}
And it's a silly example written like that, but as a cache of some Result<Any, Error>
that you cast back to the original return type and error type it makes a lot of sense.