[swift-evolution] Move placement of 'throws' statement

Tino Heth 2th at gmx.de
Tue Dec 27 07:43:03 CST 2016


> I think the problem really comes down to the inflexibility of it; if you specify X, Y, and Z as throwable types, then all code calling that method must handle those types in some way.
Imho this is no problem:
Right now, we basically have "throws Error", and no matter what is actually thrown, we can always catch exhaustive by keeping the statement unspecific.

> 	func myMethod(args:[String:Any]) throws IOError, IllegalArgumentError? { … }
Imho to much confusion with no real benefit:
Shouldn't it be up to the caller to decide which errors need special treatment? The library can't enforce proper handling at all.

One thing to note with explicit errors is that we'd basically introduce sum types… I think this wouldn't be bad at all, but afaics, core strongly favours enums (and I fear it's to late to really discuss pros and cons of both approaches)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161227/4a54229e/attachment.html>


More information about the swift-evolution mailing list