Re: Breakpoints: Swift Error
Re: Breakpoints: Swift Error
- Subject: Re: Breakpoints: Swift Error
- From: Quincey Morris <email@hidden>
- Date: Fri, 19 Feb 2016 11:08:17 -0800
- Feedback-id: 167118m:167118agrif8a:167118sUBxbFmoLe:SMTPCORP
On Feb 19, 2016, at 10:45 , Eric E. Dolecki <email@hidden> wrote:
>
> I have an app where I have a breakpoint set for Swift Error. If it's on and
> I run the debug app, I get the breakpoint for a crash.
>
> try player = AVAudioPlayer(contentsOfURL: url)
What, according to the backtrace, is the point of the error, where the throw is? Is the throw inside the AVAudioPlayer init at least?
Note that since you have a ‘try’, you have a ‘catch’ somewhere. If an error is being returned to you, you should be able to see it somewhere. If necessary, you can enclose *this* try in a do-catch construct — to get an immediate look at the error — and then end the catch block with ‘throw error’ to rethrow.
Unfortunately, using a Swift error breakpoint opens up the possibility of the debugger stopping on errors handled internally by the Cocoa frameworks, which is an annoyance for debugging your code. (You often see this problem when debugging system frameworks, such as the security framework, which are written in C++, where exceptions are also used for flow control, if you leave a C++ exception breakpoint enabled.)
The other thing to verify is that it’s stopping on a Swift error, not an Obj-C exception. In an app I’m currently debugging, I turned on the Obj-C exception breakpoint, and now it stops when instantiating a document window controller from the main storyboard. It’s something handled internally apparently, if I continue, everything is OK.
Lastly, when the debugger stops on an Obj-C exception, it usually hasn’t printed the error message to the console yet. If the error is repeatable, it’s worth clicking the Continue button (several times if necessary) to give the error a chance to be logged. If there’s nothing logged, then this may be a break you just need to ignore.
_______________________________________________
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