[swift-evolution] [idea] errors in properties

Gor Gyolchanyan gor.f.gyolchanyan at icloud.com
Tue Jul 25 15:29:38 CDT 2017


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`

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170725/69cb8217/attachment.html>


More information about the swift-evolution mailing list