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.
Fixing Bugs After Release
Moderator: Coders of Rage
-
- Chaos Rift Regular
- Posts: 173
- Joined: Thu Feb 11, 2010 9:46 pm
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: Fixing Bugs After Release
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
https://developer.apple.com/library/mac ... rence.html
http://stackoverflow.com/questions/4654 ... iphone-app
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
-
- Chaos Rift Regular
- Posts: 173
- Joined: Thu Feb 11, 2010 9:46 pm
Re: Fixing Bugs After Release
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.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
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: Fixing Bugs After Release
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.X Abstract X wrote: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.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
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.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!