# \[Pitch N+1\] Typed Throws

**URL:** <https://forums.swift.org/t/pitch-n-1-typed-throws/67496>\
**Category:** Pitches\
**Created:** [September 25, 2023, 4:25am UTC](https://forums.swift.org/t/pitch-n-1-typed-throws/67496 "2023-09-25T04:25:05Z")\
**Posts on this page:** 1\
**Showing post:** 142

<div class="post-metadata">

**Author:** ![michelf](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/michelf/32/1180_2.png) [@michelf](https://forums.swift.org/u/michelf)\
**Post date:** [October 1, 2023, 12:26am UTC](https://forums.swift.org/t/pitch-n-1-typed-throws/67496/142 "2023-10-01T00:26:10Z")

</div>

> [@dmt](#):
>
> The lack of knowledge "How to make an instance of `E`" is the key here. The only possible source of it is the failure of the call to `body`.

Not really: you could store a `E` somewhere else and throw that stored `E` instead. For instance:

```swift
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.

---

_[View the full topic](https://forums.swift.org/t/pitch-n-1-typed-throws/67496)._
