Re: Swift: should computed properties be able to throw exceptions?
Re: Swift: should computed properties be able to throw exceptions?
- Subject: Re: Swift: should computed properties be able to throw exceptions?
- From: Greg Parker <email@hidden>
- Date: Fri, 21 Aug 2015 21:11:11 -0700
> On Aug 21, 2015, at 9:00 PM, Rick Mann <email@hidden> wrote:
>
>> On Aug 21, 2015, at 20:58 , Greg Parker <email@hidden> wrote:
>>
>>> Rick Mann wrote:
>>>
>>> Also, if the method of the call site is marked as "throws," does that mean the error will propagate out?
>>
>> Nothing you write in Swift will have any effect on C++/ObjC exception unwinding.
>
> Sorry, I meant within Swift's error handling, if the call site does nothing other than be a function marked with throws, that's legal right?
>
> func
> one() throws
> {
> two()
> }
>
>
> func
> two() throws
> {
> throw something
> }
It is not legal. All call sites to methods that may throw must use `try`. The call site must explicitly acknowledge the possibility of an error.
test.swift:4:4: error: call can throw but is not marked with 'try'
two()
^~~~~
--
Greg Parker email@hidden Runtime Wrangler
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden