Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/372.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript sammy.js获取处理程序隐藏错误_Javascript_Error Handling_Sammy.js - Fatal编程技术网

Javascript sammy.js获取处理程序隐藏错误

Javascript sammy.js获取处理程序隐藏错误,javascript,error-handling,sammy.js,Javascript,Error Handling,Sammy.js,在使用sammy.js版本库0.7.4(也是0.7.1)时,发现如果在执行get处理程序函数期间发生错误,则不会向控制台打印任何内容 例如,在以下代码段中,尽管不存在名为notExistingFunction的函数,但不会向控制台打印任何内容: <html> <head> ... <script src="/path/to/jquery-1.5.2.min.js"></script> <

在使用sammy.js版本库0.7.4(也是0.7.1)时,发现如果在执行
get
处理程序函数期间发生错误,则不会向控制台打印任何内容

例如,在以下代码段中,尽管不存在名为
notExistingFunction
的函数,但不会向控制台打印任何内容:

<html>
    <head>
        ...
        <script src="/path/to/jquery-1.5.2.min.js"></script>
        <script src="/path/to/sammy-0.7.4.min.js"></script>
        ...
    </head>
    <body>
        <script>
            $(document).ready(function() {
                var sammy = Sammy(function() {
                    this.get('#someAnchor', function() {
                        // this function doesn't exist
                        notExistingFunction();
                    });
                });
                sammy.run();

                // this should lead to execution of above handler
                window.location.hash = '#someAnchor'; 
            });
        </script>
        ...
    </body>
</html>

...
...
$(文档).ready(函数(){
var sammy=sammy(函数(){
this.get('#someAnchor',function(){
//这个函数不存在
notExistingFunction();
});
});
sammy.run();
//这将导致执行上述处理程序
window.location.hash='#someAnchor';
});
...
这确实使页面的故障排除变得复杂,是否有人也经历过这种情况?这是预期的行为还是错误?有什么解决办法吗


事先多谢了

结果比我想象的要简单-在检查了sammy.js的源代码后,发现somewhy
raise\u errors
标志默认设置为
false
,用于管理错误报告

因此,将上述部分代码修改为:

<html>
    <head>...</head>
    <body>
        <script>
            ...
            sammy.raise_errors = true;
            sammy.run();
            ...
        </script>
    </body>
</html>

...
...
sammy.raise_errors=true;
sammy.run();
...
开始显示不错的错误