Page 1 of 1

Fixing Bugs After Release

Posted: Tue Aug 19, 2014 1:01 am
by X Abstract X
I've been working on a game for the past year that I plan to release on iOS/Android. Up until this point I've neglected to do any sort of meaningful error handling. Typically, I'll simply have my functions return false on error and basically close down the app. I know if I don't take steps now to integrate some sort of meaningful error handling I'll be in a world of trouble if the app starts crashing on other people's devices during testing or after release.

My question is, what sort of mechanism does everyone recommend for handling this issue?

I've seen one idea so far that seems alright. It works like this:

1. You have an Error class that would store an error message string and possibly any other useful data for fixing bugs, maybe subclass it for specific errors.
2. You keep a globally accessible stack of errors
3. Right before you do an operation that could potentially go wrong, you create an error instance and push it onto the error stack
4. Pop the error off the stack if things go smoothly
5. If an error occurs, print out the entire stack and you have a half-assed stack trace

I'm interested in hearing about your guys' approaches/opinions though before I decide on a solution.

Re: Fixing Bugs After Release

Posted: Tue Aug 19, 2014 9:05 am
by dandymcgee
Have you considered using the NSError class? This seems to be the recommended approach.

https://developer.apple.com/library/mac ... rence.html
http://stackoverflow.com/questions/4654 ... iphone-app

Re: Fixing Bugs After Release

Posted: Tue Aug 19, 2014 1:16 pm
by X Abstract X
dandymcgee wrote:Have you considered using the NSError class? This seems to be the recommended approach.

https://developer.apple.com/library/mac ... rence.html
http://stackoverflow.com/questions/4654 ... iphone-app
Actually, I'm working in 99% pure C++ so I was hoping for a cross-platform method. I'll have a look at the link though for inspiration. Thanks.

Re: Fixing Bugs After Release

Posted: Tue Aug 19, 2014 1:27 pm
by dandymcgee
X Abstract X wrote:
dandymcgee wrote:Have you considered using the NSError class? This seems to be the recommended approach.

https://developer.apple.com/library/mac ... rence.html
http://stackoverflow.com/questions/4654 ... iphone-app
Actually, I'm working in 99% pure C++ so I was hoping for a cross-platform method. I'll have a look at the link though for inspiration. Thanks.
Oh, read "iOS" and made an assumption without fully understanding your scope, sorry about that. The NSError implementation could serve as a useful example I suppose.

Anyway, the custom class you described sounds exactly like how Exceptions work in C#. The major difference is that your resources aren't managed in C++. You need to be careful about how you throw errors to be sure you're not skipping over code which releases unmanaged resources.