[swift-evolution] [Pitch] Typed throws

Russ Bishop xenadu at gmail.com
Fri Feb 24 00:36:49 CST 2017


> On Feb 21, 2017, at 8:18 AM, Joe Groff <jgroff at apple.com> wrote:
>>> 
>> 
>> Yeah but Rust has a macro system so error-chain makes re-wrapping trivial. A simple `chain_err(|| “my new error message”)` is enough to define and “throw” a new error that wraps the underlying error.
> 
> That was my point—they recognized error chaining/layering as a common phonemenon and provided affordances for it as part of their design. I was saying we should do the same if we investigate typed errors seriously. (Not sure why you mentioned macros—chain_err is just a regular method, and could be defined as an extension method on Error in swift today.)
> 
> -Joe

Sorry, I meant error_chain! handles the boilerplate. At the end of the day something has to create the new error types.

I agree with you on the chaining; if we really do want to go down this road we need an elegant solution. Seeing people talk about getting rid of rethrows makes me think this isn’t yet a serious discussion.

Russ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170223/b45f34d1/attachment.html>


More information about the swift-evolution mailing list