idea: try/catch and "rethrow"...?

Mike Shaver mike.shaver at gmail.com
Tue Feb 1 11:06:22 PST 2011


On Tue, Feb 1, 2011 at 10:53 AM, Kyle Simpson <getify at gmail.com> wrote:
> ?I have something that annoys me about how JavaScript try/catch error
> handling currently works. Don't get me wrong, I totally understand why it
> works that way, and it makes sense. But having the option to get around that
> behavior would be really nice.

I believe that catchguards have been accepted as Harmonious.
Spidermonkey has had them since the ES3 days, but they weren't
standardized due to making things too hard for someone's debugger.

try {
  throw 5;
} catch (e if e == 4) { // not caught
   four(e);
}

try {
  throw 5;
} catch (e if e == 4) {
  four(e);
} catch {  // fallback
  other(e);
}

Mike


More information about the es-discuss mailing list