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

<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:** [September 28, 2023, 6:17pm UTC](https://forums.swift.org/t/pitch-n-1-typed-throws/67496/103 "2023-09-28T18:17:57Z")

</div>

> [@tikitu](#):
>
> But, I was trying to do something that you really shouldn’t do. (Relying on implementation details of which more-specific-error-cases are sent in which error conditions, which are _not_ documented as a library contract and _not_ a straightforward consequence of the semantics of the errors.)

[The error conditions _are_ explicitly documented](https://developer.apple.com/documentation/swift/singlevaluedecodingcontainer/decode(_:)-4apkx). You _should_ be getting `DecodingError.typeMismatch` in this case, which the API is documented as returning "if the encountered encoded value cannot be converted to the requested type" which is definitely the case you're interested in.

Tangentially, this also harkens back to my earlier point that I think it should be possible to specifically list enum _values_ in what's thrown, not just whole enum types, as not every API is supposed to be able to throw every value from a given enum (and refactoring things into a distinct enum for each function, while a workaround, might prove a bit repetitive and tedious).

---

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