# \[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:** 170

<div class="post-metadata">

**Author:** ![wadetregaskis](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/wadetregaskis/32/8494_2.png) [@wadetregaskis](https://forums.swift.org/u/wadetregaskis)\
**Post date:** [October 2, 2023, 5:33am UTC](https://forums.swift.org/t/pitch-n-1-typed-throws/67496/170 "2023-10-02T05:33:24Z")

</div>

> [@xwu](#):
>
> This formulation, notably, does not permit catching an error, wrapping it, and then throwing, because it is not "throw[ing] by either calling a function that is rethrowing-only for _f_ or calling a function that is `rethrows`, passing only functions that are rethrowing-only for _f_."

I'm not sure that's the correct interpretation. Or at least, it's not the only viable interpretation. I find that section of that internal compiler documentation very hard to understand in any case, but as best I can decipher it seems to say a rethrowing function can throw only if a function it calls throws - it does _not_ specifically say the thrown error has to be passed up as-is. I interpret it as alluding only to the _timing_ at which an exception can be thrown, not any restriction on what is thrown.

The actual [Swift Language Reference](https://docs.swift.org/swift-book/documentation/the-swift-programming-language) [describes `rethrows`](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/declarations#Rethrowing-Functions-and-Methods) much more clearly and _explicitly_ says catching and throwing a different exception is permitted:

> A rethrowing function or method can contain a `throw` statement only inside a `catch` clause. This lets you call the throwing function inside a `do` -`catch` statement and handle errors in the `catch` clause by throwing a different error.

I think the actual Language Reference is the authoritative definition of intended functionality, because it's what the _users_ of Swift actually learn from and rely on. Even if somehow its definition of `rethrows` was technically inaccurate at some point, it's now the definition de facto.

---

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