View Full Version : XCode - how to "see" an exception that is thrown
Apr 10, 2009, 08:25 PM
I'm trying to follow the lesson for Core Date in the "Cocoa Programming for Mac OS X" book, 3rd ed. (Ch.11), and I built an app using Core Data (so I didn't write any code - it's all IB connections and bindings) that when I run, an exception is thrown. But I have no idea how to figure out what threw the exception or why. Since I didn't write any code myself, it doesn't show an error on a particular line of code.
The exception is thrown right when the program starts.
In the debugger, in the Thread list, it shows:
1 +[NSException raise:format:arguments:]
2 +[NSException raise:format:]
Does that mean the formatter I applied to one of the columns in my table view is wrong somehow? There is no data yet, as the program just started - so the table view is empty.
Can anyone help shed some light?
Apr 10, 2009, 09:57 PM
Heh... you deleted the most useful part of the backtrace. Show us the rest of it.
Also, something should be logged to the console that should help you out.
It's likely one of your bindings are set up incorrectly.
Apr 11, 2009, 07:56 AM
I'm sure it's either one of my bindings or one of my connections as I didn't actually write any code. I think my issue is just not knowing how to decipher the backtrace and other debugger output.
Here's the full backtrace:
#0 0x934f2e17 in objc_exception_throw
#1 0x971a3eeb in +[NSException raise:format:arguments:]
#2 0x971a3f2a in +[NSException raise:format:]
#3 0x95c09126 in -[_NSManagedProxy _entity]
#4 0x95c09379 in -[_NSManagedProxy fetchRequestWithSortDescriptors:limit:]
#5 0x95aab8cc in -[NSArrayController(NSManagedController) defaultFetchRequest]
#6 0x95c08a74 in -[NSObjectController(NSManagedController) _executeFetch:didCommitSuccessfully:actionSender:]
#7 0x95d3803e in _NSSendCommitEditingSelector
#8 0x95b1ed54 in -[NSController _controllerEditor:didCommit:contextInfo:]
#9 0x971a9a3d in __invoking___
#10 0x971a9428 in -[NSInvocation invoke]
#11 0x971a94f8 in -[NSInvocation invokeWithTarget:]
#12 0x94a5022e in __NSFireDelayedPerform
#13 0x9712ab25 in CFRunLoopRunSpecific
#14 0x9712acd8 in CFRunLoopRunInMode
#15 0x94cbd2c0 in RunCurrentEventLoopInMode
#16 0x94cbd0d9 in ReceiveNextEventCommon
#17 0x94cbcf4d in BlockUntilNextEventMatchingListInMode
#18 0x95709d7d in _DPSNextEvent
#19 0x95709630 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]
#20 0x9570266b in -[NSApplication run]
#21 0x956cf8a4 in NSApplicationMain
#22 0x00001f93 in main at main.m:13
The output of the console doesn't show anything, here it is from start to finish:
[Session started at 2009-04-11 08:50:24 -0400.]
Loading program into debugger…
GNU gdb 6.3.50-20050815 (Apple version gdb-962) (Sat Jul 26 08:14:40 UTC 2008)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin".tty /dev/ttys000
sharedlibrary apply-load-rules all
[Switching to process 52561 local thread 0x2d03]
Apr 11, 2009, 11:45 AM
So, is that exception not crashing your program? If you were to continue after breaking on it, do you see a log message then?
It looks like you're binding to a CoreData model. I'm not an expert on CoreData by any stretch of the imagination, but it looks like you're asking the CoreData model for an entity that doesn't exist and it doesn't know how to proceed so it throws an exception.
If you're still clueless, the best approach I can suggest is to debug manually by removing your bindings one at a time and running your program until the exception isn't thrown. Of course, there might be multiple bad bindings, which means you might need to try removing more than one at a time.
Apr 11, 2009, 12:13 PM
Yes, if I press "Continue" a few times, eventually a friendlier error message appears in the console telling me an entity could not be found - in one of my bindings I used "Cars" instead of "Car".
Thanks for the hint!