[swift-evolution] [Proposal] Typed throws

Anton Zhilin antonyzhilin at gmail.com
Sun Feb 19 14:16:36 CST 2017


2017-02-19 22:59 GMT+03:00 Matthew Johnson <matthew at anandabits.com>:

On Feb 19, 2017, at 1:32 PM, Anton Zhilin <antonyzhilin at gmail.com> wrote:
>
> Now that I think about it, generic throws does not exactly cover rethrows.
> Firstly, rethrows has semantic information that function itself does not
> throw—it would be lost.
>
> Can you elaborate further on what you mean by this?
>
protocol Default { init() }

func exec(f: () throws -> Void) rethrows
{
    try f()
    throw MyError()  // error because of rethrows
}

func exec<E>(f: () throws(E) -> Void) throws(E)
     where E: Error & Default
{
    try f()
    throw E()  // okay
}

​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170219/a7cff9a1/attachment.html>


More information about the swift-evolution mailing list