views:

120

answers:

4

Hi,

Are there any frameworks that capture and report exceptions? I need something that catches any exceptions or errors caused by my program while its being used by a non-technical user and then to email it to me. Do you handle this on your own projects? Did you roll your own solution or is there an off the shelf solution?

Any help would be greatly appreciated.

A: 

Well, there is @throw with NSException, e.g.:

@throw [NSException exceptionWithName:@"xxx" reason:@"yyy" userInfo:nil];

and [NSException raise:], see adc and this question.

Ramashalanka
I think the OP was asking for a framework that would send the exception info to the developer. Oddly enough, I was reading [Red Sweater Blog](http://www.red-sweater.com/blog/439/crappy-crash-logs) right before this. As of late 2007 it doesn't look like there was a framework to send the reports in. A few people in the comments mention rolling their own.
kubi
Yeah, but I don't want to pepper my code with calls to functions to send emails and such. I wonder if there's a higher level way of doing things.
Rui Pacheco
True. http://developer.apple.com/tools/xcode/symbolizingcrashdumps.html is a start, but it looks like the emailing needs to be home grown.
Ramashalanka
A: 

Exceptions are typically used in Cocoa for denoting programmer error as opposed to something going "oops" at runtime.

The classic example of the former: An Array out of bounds exception occurs if you tried accessing the 50th element of a 10 element NSArray. This is programmer error as you should not let this happen.

The classic example of the latter: You try to read in a file from disk but the file is missing. This is not an exceptional case, it's somewhat common for file read operations to fail, and thus an exception should not be thrown (it's your job as a Cocoa developer to recover from this gracefully, and it's not too difficult to do so).

Keep this in mind when using Exceptions in Cocoa, especially if they are going to be user-facing.

jbrennan
True. But developers are human and I'd like to spare my users the trouble of sending me bug reports - let the application handle that.
Rui Pacheco
A: 

This may not be exactly what you are looking for, but if you use Fogbugz, there is a tool called Bugzscout that will create a ticket from the application. You could tie it into to your exception and give the user an opportunity to create a ticket on the exception:

http://www.fogcreek.com/FogBugz/docs/70/topics/customers/BugzScout.html

Ricky Nelson
A: 

Found the answer in this thread.

Rui Pacheco