Typed throw functions

You're right. It is a non-goal (in my opinion) for Swift's error handling to be as expressive as TypeScript or Java's error handling. Its only goal is to be great for Swift.

On a few other points, yes, closures (and function types in general) should support typed throws. rethrows should not take a type, it should propagate the type from the closure to the callee. This would make sure that:

   try { 
     ... = try thing.map { foo($0) }
   } catch let x {
   }

infers x to FooError if foo is a function that throws only FooError.

-Chris

5 Likes