[Alephmodular-devel] More on Errors
Status: Pre-Alpha
Brought to you by:
brefin
From: Br'fin <br...@ma...> - 2003-02-02 18:45:17
|
I decided to just focus on implementing errors for a bit. Implement it, check it in, then get back to files. So I've been working on game_errors.h and replacing the functionality in there with an implementation of IFailable. This isn't the best example since it's an effect that looms over the whole game code, but replacing usage of set_game_error and such with an IFailable interface seemed a good way to neaten the IFailable stuff up. As a result I did find some places where returning a constant reference is better than dealing with passing the reference. (Note in the sample below how the error is retrieved from the class) Old method: if(error_pending()) { int16 type; err= get_game_error(&type); dprintf("Er: %d type: %d", err, type); set_game_error(systemError, noErr); } New method: if(!GameErrorState.is_good()) { CError err = GameErrorState.get_error(); dprintf("Er: %ld type: %d", err.get_code(), err.get_type()); GameErrorState.clear_error(); GameErrorState.set_error(CError(CError::systemError, CError::errNone)); } As a result of this, I must say that I am waffling over is_good and error_pending as that is the only part I really feel unhappy with. Oh, and I suppose GameErrorState is lame too. But I couldn't tell you when we might have good and proper top of the tree state objects for the game. -Jeremy Parsons |