Added "new Error()" to throw statements so that message and stack
can be properly reported in catch statements. (Not tested).