Checking if an OverlayElement exists...

Problems building or running the engine, queries about how to use features etc.
Post Reply
big_o
Goblin
Posts: 279
Joined: Sun Feb 19, 2006 1:08 am

Checking if an OverlayElement exists...

Post by big_o »

...without getting struck by an exception if it doesn't :? .

I'm working on the GUI of my game and thought that rather than destroying and recreating the overlay containers used for the windows and such I would just create them once and grab the overlays after that.

The only problem is that the getOverlayElement method in OverlayManager throws an exception when you try to get an element that doesn't exist.

It's not really a big deal, but if anyone might know of a way to get around this, I would appreciate it.
quex
Gnoblar
Posts: 5
Joined: Thu Jan 18, 2007 11:40 pm

Post by quex »

Why not just put your getting code inside a try and catch statement? that way you can log which containers exist and which don't?

Code: Select all

try
{
     //Do your grabbing code here
}
catch(...)
{
     //The element doesn't exist. Log it
}
big_o
Goblin
Posts: 279
Joined: Sun Feb 19, 2006 1:08 am

Post by big_o »

Thanks, I'll try that.

I'm new to exceptions at the moment.
Post Reply