added JS event handler for error reporting