[swift-evolution] Best way to handle escaping function that might throw

Howard Lovatt howard.lovatt at gmail.com
Mon Jan 9 23:21:39 CST 2017


Hi,

If I have an escaping function that I store and then call, I need to
declare the calling function as throwing, not rethrowing. EG:

    struct FStore {
        let f: () throws -> Void
        init(f: @escaping () throws -> Void) { self.f = f }
        func call() throws { try f() } // Can't put rethrows here - have to
use throws
    }
Is there a better solution?

Thanks for any suggestions,

  -- Howard.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170110/93e0ec3a/attachment.html>


More information about the swift-evolution mailing list