Failing gracefully
Posted: 22 Jul 2009, 15:40
If your code does not work, it should fail gracefully.
Its a nice and simple concept. It allows you to tell the user why it failed ( or that it failed at all ). "My spring crashes randomly" versus "ABCAI does not support this version of BA, XYZAI carrys on working", which sounds more helpful?
A program should never crash due to improper environments or bugs. It should detect or catch the problem in progress, shut itself down, send of error reports for analysis, and give the user details of what happened and tell them the program is unable to continue.
Its a nice and simple concept. It allows you to tell the user why it failed ( or that it failed at all ). "My spring crashes randomly" versus "ABCAI does not support this version of BA, XYZAI carrys on working", which sounds more helpful?
- If your AI only supports a handful of games, make sure it tells the user when it finds itself running under a non supported game.
- Dont crash
- Don't continue to run code once you know that a crash is inevitable, check for a boolean if its ok to continue and halt before any AI routines are executed if its not possible.
- Self destruct all AI units if you want, its still better than crashing spring.
- Write out error logs
- Stop continuing execution when an exception is thrown, and catch exceptions, don't let them propagate to the engine
- Collect bug reports on a crash
This is nonsense, lazy programming, failure to accept responsibility for your own crashes, ignorance of bugs in your code base, improper debugging, and downright irresponsible development.We should let spring crash so that the user knows something is wrong because the AI is not going to work anyway
A program should never crash due to improper environments or bugs. It should detect or catch the problem in progress, shut itself down, send of error reports for analysis, and give the user details of what happened and tell them the program is unable to continue.