为什么尝试捕获高图构造函数不会捕获错误#12但错误#19?

时间:2017-04-17 21:30:58

标签: highcharts

我正在使用highcharts 4.0.4并尝试捕获渲染过程中发生的任何错误。

我能够捕获错误#19,但是当错误#12发生时,控件不会进入catch块。有谁知道可能是什么原因?

1 个答案:

答案 0 :(得分:0)

错误#12的函数调用在没有第二个函数参数error(12);的情况下完成。第二个函数参数负责停止代码执行,因此代码不会停止。

Highcharts 4.0.4中的代码:

/**
 * Provide error messages for debugging, with links to online explanation 
 */
error = function (code, stop) {
    var msg = 'Highcharts error #' + code + ': www.highcharts.com/errors/' + code;
    if (stop) {
        throw msg;
    }
    // else ...
    if (win.console) {
        console.log(msg);
    }
};

在Highcharts 5.0.0+中,可以使用您自己的代码override/extend/wrap错误函数。

相关问题