(I’m going to reply over here since the discussion from the spun-off topic came back around to typed throws)
I think “too lazy to actually think things through” is an unfair characterization. The way I see Swift exceptions (and I am, again, no expert in CS) is that when you are performing operations that could fail in various ways those operations should throw an error, some of which may be recoverable and others won’t be.
What I, as the programmer, should do is reason about what makes sense for me to handle and look for that, and propagate the rest “up the chain” (if there is an “up”) for anything else that can handle it (or bail out completely, if that’s more appropriate). In that way, only the errors that I can do something about matter. The current state of Swift’s Error
works well in this scenario as I can catch
whatever I know I can handle and either throw
or crash for the rest.
I’ve been participating in discussions here for several years now and the topic of typed throws has cropped up several times, and it genuinely excites a handful of community members each time, but I have never seen anyone actually enumerate the benefits of having a throw
with a concrete type before this thread. Even then, the only specific benefit I’ve seen clearly communicated here is that it’s necessary for Embedded Swift.