[793] in Coldmud discussion meeting

root meeting help first first in chain previous in chain previous next next in chain last in chain last

Re: exception handling...

daemon@ATHENA.MIT.EDU (Thu Aug 31 18:32:18 1995 )

Date: Thu, 31 Aug 1995 16:24:05 -0600
From: 869683 Gillespie Brandon James <brandon@smithfield.declab.usu.edu>
To: coldstuff@MIT.EDU

< This isn't an exception handler, it's a switch statement.

No, it is both.  Yes, I'm aware of its similarity with a switch statement,
but it is cleaner and more succinct than the current method, in conjunction
with a switch, ala:

for obj in (list) {
    catch ~locked {
        obj.query_test();
        sender().print("Test is sucessful for: " + obj.name());
        valid = valid + [obj];
    } with {
        switch(error()) {
            case ~locked:
                sender().print("Object is locked.");
            default:
                sender().print("Error: " + toliteral(error) + " encountered!");
        }
    }
}

(vs:)                 

for obj in (list) {
    catch { 
        obj.query_test();
    } handle ~locked {
        sender().print("Object is locked.");
    } handle others {
        sender().print("Error: " + toliteral(error) + " encountered!");
    } finally {
        sender().print("Test is sucessful for: " + obj.name());
        valid = valid + [obj];
    }
}

Like I said, its mainly a small change.  However, my goal is to get it 
to a 3-stage handler, rather than the 2-stage one it is at now.  I.e.
currently you have "error->oops, do this", Richelieu brought up that it
would be nice to do 3 stages, ala "error, try this, otherwise this".  I'm
just having a hard time finding a good way to do it.

-Brandon