[Alephmodular-devel] On errors
Status: Pre-Alpha
Brought to you by:
brefin
From: Br'fin <br...@ma...> - 2003-01-31 15:22:51
|
In general, I like the design I put forth for IFailable. It's intent was not to cover an object handled by several threads at once. The area I'm having problem is with with CError objects. As I work on it, I'm going lets add this and lets add that. And consequently it seems to be lacking a proper elegance to it. Marathon handles errors like so: The game hits an error and calls set_game_error(type, code) Type may be a gameError or a systemError. If it's a gameError, than code is limited to a particular subset of codes. If it's a systemError, than the particular error is recorded in the code. Code higher up the hierarchy can check if the game has an error_pending, it can read what kind of error is around with get_error and can clear the error. For instance, file finding code might report (systemError, fileNotFound) Further up the code sees this and says: Error pending? Ok, what is it? File not found? Ok, it's just the preferences, clear the error and continue on to create the file. For a contrasting viewpoint on errors, I looked at Java. That has the hierarchy of 'Throwable' leading to 'Exception' (things which your program should catch) and 'Error' (Things which your program shouldn't catch, they're just too big). And then further breakdowns of errors. In our case this would work out to one SystemException and then GameException with a hierarchy of specific exceptions beneath it. Another thing about Java exceptions is that the interface is fairly simple, You create a new exception and the string argument in the creator is optional. Hsm, was just thinking about exceptions and C++. Exceptions get to be a nuisance if the current function itself is just a pass through for an exception. (open_preferences would continue to throw a fileNotFoundException that originated in open_file and also had to propagate through wad_open.) Or do you just need to pussyfoot around your declarations to make sure that if you're passing an exception that you didn't declare any memory before the point where the exception can occur? -Jeremy Parsons |