fixed one infinite loop bug - when an error occurs

before the js_Window is accessed, the code to notify the error count changed
as infinite looping.