Skip to main content
gamedev.net
🔒 Locked

Error Management System

Started by Penance Dec 7, 2005 at 9:52 PM 0 replies 800+ views
Original Post
Penance
Penance
Just wondering what systems people use to manage error handling and logging in their systems. Right now my engine has a static LogManager object (m_log_manager) and a static method public static void HandleError(Exception e); HandleError takes the exception, pulls out interesting stuff and then calls m_log_manager.WriteToLog("ERRORS", "the log entry's text"); In all my utility code that I've written I don't try/catch anything because retrowing errors is expensive and usually the code isn't able to handle the error anyway since there's no guarantee about what kind of setup the code will be run under. For example, I might not be writing a console app, so catching and printing to a console is useless. Anytime my engine calls a method that can throw an exception, I wrap a try/catch around it and call HandleError in the catch block. Do you think this is a good setup or could I do better?
Telastyn
Telastyn
I don't have a nice neat error handling setup. Generally, I try to design things to not fail, even if that means drawing an empty box, playing a silent sound, or even exiting without doing anything. The errors will generally be logged, and the sort that can't 'fail softly' will know how to exit cleanly.

For logging, various sub-systems/modules/parts will have a local log assigned to them. The log is actually just an interface that takes strings and dumps them. Different concrete implimentations will determine where the string ends up, be it to the screen, file, or even nowhere. Other loggers can act as decorators [pattern] to add things like current memory usage, time, and other gamestate info to the strings.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.