[swift-evolution] [idea] errors in properties
Jacob Williams
ponyboy47 at gmail.com
Tue Jul 25 15:58:35 CDT 2017
I’d give my +1 to support this as I’ve wished at one time or another that I could throw in the get, set, willSet, or didSet.
Would this be something a proposal should be written up for when the Swift 5 reviews begin?
> On Jul 25, 2017, at 2:55 PM, Xiaodi Wu via swift-evolution <swift-evolution at swift.org> wrote:
>
> There have been a number of discussions on the list in this—Google finds a number of these with a search “swift throwing properties site:lists.swift.org <http://lists.swift.org/>”.
>
> The “tldr” seems to be that it’s not supported because no one has written code to support it yet.
> On Tue, Jul 25, 2017 at 15:29 Gor Gyolchanyan via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
> I’ll just cut to the chase:
> Why is throwing from get, set, willSet and didSet disallowed?
>
> var login: String {
> willSet throws {
> guard newValue.count > 5 else {
> throw LoginError.loginTooSmall
> }
> }
> }
>
> try login = “JebediahKerman” // totally fine
> try login = “Bob” // throws `LoginError.loginTooSmall`
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170725/42421346/attachment.html>
More information about the swift-evolution
mailing list