用于 Visual Studio 的 Node.js 工具总是在出现异常时停止

标签 node.js visual-studio debugging ntvs

所以我一直在使用 Visual Studio 的 Node.js 工具 ( https://nodejstools.codeplex.com )。

我有这个反复出现的问题,当出现异常时它总是会开始调试。这听起来像是一件好事但当异常应该被捕获时就不是这样了!

以此为例(这是来自bson模块)

try {
    // Load the precompiled win32 binary
    if(process.platform == "win32" && process.arch == "x64") {
      bson = require('./win32/x64/bson');  
    } else if(process.platform == "win32" && process.arch == "ia32") {
      bson = require('./win32/ia32/bson');  
    } else {
      bson = require('../build/Release/bson');  
    }   
} catch(err) {
    console.error("Failed to load c++ bson extension, using pure JS version");
    bson = require('../lib/bson/bson');
}

这里将在使用纯 JS 版本被捕获之前进入调试,这是预期的行为,但我希望 VS 避免在之后被捕获时启动调试...(这清楚吗?)

我的临时解决方案是转到 Debug/Exceptions/Node.js Exceptions 并为 Error 下的所有内容取消选中“Thrown”...但是当我遇到真正需要抛出的错误时,调试器不会选择它们.

也许这只是工具的局限性,因为它很新,但如果其他人找到了解决方案,那将非常有帮助!

最佳答案

NTVS currently reports all exceptions whenever they are thrown - we can't determine whether they're caught somewhere up the stack. Those missing module exceptions are virtually always caught. For the time being, you can add this exception type to Debug -> Exceptions, and disable breaking on it, if you don't want to press F5 every time to move on. In the upcoming beta release, this setting will be there by default.

http://nodejstools.codeplex.com/discussions/538432

关于用于 Visual Studio 的 Node.js 工具总是在出现异常时停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22676142/

相关文章:

node.js - vscode调试打不到断点 'Program path uses differently cased character as file on disk'

node.js - 声明自定义异常以与 Firestore 可调用函数和 VueJS 一起使用

php - 在社交网络上存储文件的最佳方式

jquery - jQuery 智能感知插件现在可用于 Visual Studio 吗?

debugging - 退出显示图像OpenCV时堆损坏

ruby-on-rails - 有什么方法可以判断在运行时为 Rails 进程加载了哪些 gem 和插件?

php - Laravel 5.1 使用 Redis

javascript - 未处理的 promise 拒绝: TypeError: Cannot read property 'username' of undefined

visual-studio - 用于 Elastic Beanstalk 配置以安装 Visual C++ Redistributable 的命令

visual-studio - 在构建前或构建后事件中请求用户输入 - Visual Studio