swiftlang / swift-book

The Swift Programming Language book
Apache License 2.0
1.75k stars 161 forks source link

Update error handling for typed throws [SE-0413] #296

Closed amartini51 closed 5 months ago

amartini51 commented 6 months ago

Fixes: rdar://118896654

amartini51 commented 6 months ago

Proposal authors, @DougGregor @minuscorp @torstenlehmann, can you please review for technical accuracy?

I've adjusted the framing of when to use typed throws slightly, compared to the SE proposal. The discussion in the SE proposal of implementation details and dependency-free code seems overlap in the sense that the errors aren't part of the code's API to its clients. When vending a throwing API, it's important to use throws(any Error).

I haven't yet added a comparison of throws(T) to rethrows. Do we want to recommend the typed throws spelling in general, or is there still a reason you might want to use rethrows? For example, rethrows still enforces the constraint that errors can come only from called code.

minuscorp commented 6 months ago

It looks good to me 👍

rebeccateibloom commented 5 months ago

@amartini51 I read through your comments and the latest commit. I marked a few of my past comments/queries as resolved. Thanks for the patient explanations!