Re: [Alephmodular-devel] More on Errors
Status: Pre-Alpha
Brought to you by:
brefin
From: Br'fin <br...@ma...> - 2003-02-04 01:53:47
|
Ok, after some more working and thinking, this particular code snippet now comes out like: if(AlephModular.bad()) { CError err = AlephModular.get_error(); dprintf("Er: %ld type: %d", err.get_code(), err.get_type()); AlephModular.clear_error(); } Two things to note here. is_good() was replaced with good() and bad() (Though I resisted the temptation to go the whole way that iostream does which overrides things so if(cin) is the same as if(cin.good()) and if(!cin) is the same as if(cin.bad())) :) And the other is I renamed GameErrorState to be AlephModular. Why? Well, the specific class that AlephModular is a variable of is called GameState. And it seems that such a class would be a reasonable 'owner' of all the dynamic info in the game. For instance, AlephModular.save_game(IFileDesc) would dump out everything the game needs to reload itself. I admit that this sort of dynamic ownership of game state is still off in the future, but it does seem to be food for though. I admit that game_errors.h isn't the best place for this class in the end, but seeing as its subsuming the game_errors.h functionality it seemed like the best place to drop it initially. -Jeremy Parsons On Sunday, February 2, 2003, at 01:45 PM, Br'fin wrote: > 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 |