Wednesday, May 02, 2007

JScript try catch syntax

I alway forget the syntax for JScript exception handling and searching on the web always seems to bring up the wrong thing, so here is an example as my own personal reminder.

    try
    {
        // do stuff
        return "blah";    
    }
    catch(e)
    {
        return e.message;
    }

Yeh, I know, I should be able to remember that... I blame it on the crap JScript editors, none of which provide the mental crutch of code completion.

Remember too, JScript requires the e, you can't use catch().

1 comment:

Scott_tcg said...

Thanks, I'm new to jScript and always looking for syntax.
Microsoft has gone the opposite, full legal document with more bs than you asked.
I remember the day …
when you hit F1 and it gave you just what you wanted