Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting python exceptions printed the normal way with PyObjC

I'm getting errors like this:

2010-07-13 20:43:15.131 Python[1527:60f] main: Caught OC_PythonException: : LoginMenuSet instance has no attribute 'play_sound'

That's with this code:

@try {
    [section loop]; //Loop through section
} @catch (NSException *exception) {
    NSLog(@"Caught %@: %@", [exception name], [exception reason]);
}

I want the python exception to be printed normally with the traceback and everything else.

Thank you.

like image 388
Matthew Mitchell Avatar asked Jul 13 '10 19:07

Matthew Mitchell


1 Answers

One trick to see Python exceptions is to call objc.setVerbose(1). This makes PyObjC slightly more verbose and causes it to print Python stack traces when converting exceptions from Python to Objective-C.

like image 168
Ronald Oussoren Avatar answered Nov 20 '22 06:11

Ronald Oussoren