Error Handling in Cross Platform Game Engine

Started by
4 comments, last by Raeldor 18 years, 1 month ago
Hi All, How would you do this? Would you simply use boolean returns from functions to indicate success or failiure, or would you implement your own error numbers? Would you use an XML file or something to link error numbers to error descriptions? Can XML handle unicode or international lanuages? Thanks
Advertisement
Exceptions with descriptions attached, and logging to file and console wherever the exception is caught.

And yes, XML can handle that stuff. Just use UTF-8 encoding and mark it appropriately in the header.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Why not just use a try/catch block and implement classes to handle specific error conditions? As far as I'm aware (correct me if I'm wrong) try/catch is part of the C++ standard (assuming you're using C++ but VB/C# also have their own try/catch blocks) and is not tied directly to any platform:

try{   // problem encountered   throw CSomeExceptionClass();}catch( CSomeExceptionClass var ){   // do something here with the exception class}catch( ... ){   // apparently something happened you weren't expecting but   // catch it anyways and handle it as gracefully as you can   }

As for your question about XML yes it will handle international languages as long as you properly set the encoding in the xml declaration. Just be careful though as the same rules apply when using international languages as when using standard UTF-8 regarding invalid characters.
Thanks for the replys. For stuff that's not a catastrophic failiure, are error numbers still a good way to go to trap the conditions? Should I try and keep consistency and have an error number returned from a failed function even if there is only one point of failure, or should I just return a bool from that function?

I am thinking more of support functions here, such as reading incorrect values from a file, etc.
I'd go for consistency. Less thinking that way, you avoid the pain of having to change your bool to an int if the function gets more complex, etc.

Geoff
Cool, thanks for the insights.

This topic is closed to new replies.

Advertisement