Jump to content
  • Advertisement
Sign in to follow this  
Raeldor

Error Handling in Cross Platform Game Engine

This topic is 4517 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!