About Exceptions

Game development with Board Game Arena Studio
Post Reply
User avatar
tilalilalou
Posts: 78
Joined: 05 August 2011, 08:40

About Exceptions

Post by tilalilalou »

Hi,

I would like some explanations about feException : this exception appears in many game as well as in the zombie method sample, but it is not documented anywhere. Is it obsolete ? What should be used instead ? BgaSystemVisibleException ?

Another question about exceptions : if the system receives an unexpected parameter value from the client (something the client should not be able do send without hacking), what should be used ? BgaUserException or BgaSystemVisibleException or BgaSystemException ?
For example, if the system uses game state arguments to tell the client which action can be done, so as the client only permits clicks on valid action, how should the server react to an forbidden action ?

Thanks,

Tilalilalou
User avatar
sourisdudesert
Administrateur
Posts: 4630
Joined: 23 January 2010, 22:02

Re: About Exceptions

Post by sourisdudesert »

Hello,

Yes, this is better to use specialized exception like BgaSystemVisibleException, this is why feException is not documented.

About your case, you just have to ask the question: "if anything goes fine (technically speaking), can this exception happens?". If the answer is Yes, you should use BgaUserException. Otherwise, you should use BgaSystemVisibleException most of the time, and BgaSystemException is extreme rare case when some unsecure information (ex: SQL query) are used in the exception message.

So:
_ unexpected parameter that can result from a hacking => BgaSystemVisibleException
_ wrong action: you don't have to worry about that: self::checkAction is triggering the right exception for you ;)

Cheers,
User avatar
tilalilalou
Posts: 78
Joined: 05 August 2011, 08:40

Re: About Exceptions

Post by tilalilalou »

Thanks for your answers,

I updated "Main game logic" wiki page, there was an feException left in zombie mode section.
This could be a good idea to replace every feException in existing games code (at least in sample ones), so the new developers do not copy-paste feException like I did ;)

Tilalilalou
User avatar
tilalilalou
Posts: 78
Joined: 05 August 2011, 08:40

Re: About Exceptions

Post by tilalilalou »

Hello,

Tonight I had this error on the studio while trying to throw a BgaSystemVisibleException :

Code: Select all

Server syntax error: Warning: require_once(/var/www/tournoi/include/BgaSystemVisibleException.inc.php): failed to open stream: No such file or directory in /var/tournoi/release/tournoi-130509-1914-gs/www/index.php on line 43 Fatal error: require_once(): Failed opening required '/var/www/tournoi/include/BgaSystemVisibleException.inc.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/tournoi/release/tournoi-130509-1914-gs/www/index.php on line 43
My code is the following :

Code: Select all

throw new BgaSystemVisibleException("Invalid resource: " . $type);
Is there something wrong on my side ?

Thanks,

Tilalilalou
User avatar
sourisdudesert
Administrateur
Posts: 4630
Joined: 23 January 2010, 22:02

Re: About Exceptions

Post by sourisdudesert »

Hello,

There was a mistake in the documentation: it's "BgaVisibleSystemException" and not "BgaSystemVisibleException".

Sorry for this.

Cheers,
Post Reply

Return to “Developers”