spraff spraff - 1 year ago 87
Javascript Question

Why does Google Closure think Exception is undefined?

I tried running Google's Closure Compiler on my code with


This simple statement

throw new Exception ("hello");

yields an error

variable Exception is undeclared

I thought
was standard. Is Closure wrong, or should I be declaring Exception somehow before throwing it? (My code runs fine in Firefox.)

Answer Source

You should be throwing Error's instead of Exception's:

throw new Error('hello');

(throw new Exception() doesn't work in my Firefox, not sure why it works for you)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download