fixed handling of JS errors (#86)