fix 'ReferenceError: error is not defined'

There is no variable 'error' defined, so the error case fails. I changed it to throw a new generic Error which fixes the problem.
Merge pull request #1 from caseman/patch-1

fix 'ReferenceError: error is not defined'