[Pitch N+1] Typed Throws

The error conditions are explicitly documented. 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).

1 Like