Updated JS error reporting code