【问题标题】:node-tunnel/node-https: If authentication parameters are bad or any proxy parameter is bad, exceptions are thrownnode-tunnel/node-https:如果认证参数错误或任何代理参数错误,则抛出异常
【发布时间】:2021-07-27 10:41:57
【问题描述】:

我们在电子应用程序中使用节点隧道 (https://github.com/koichik/node-tunnel) 来处理代理请求。 如果身份验证参数错误或任何代理参数错误,则会引发异常。有没有办法捕获这些异常并向用户显示出了什么问题?

【问题讨论】:

    标签: node.js https electron http-proxy


    【解决方案1】:

    你可以在你的项目中使用 try catch 来捕捉错误,一旦你捕捉到错误,你就可以将它展示给用户

    try {
      console.log("entering try block");
      throw "thrown message";
      console.log("this message is never seen");
    }
    catch (e) {
      console.log("entering catch block");
      console.log(e);
      console.log("leaving catch block");
    }
    finally {
      console.log("entering and leaving the finally block");
    }
    

    【讨论】:

    • 我在 https 请求中尝试了 try-catch。由于异步性质,它无法正常工作。这个异常是从第三方模块抛出的.. 到目前为止无法捕捉到
    猜你喜欢
    • 2012-08-26
    • 2020-10-23
    • 1970-01-01
    • 2013-02-10
    • 1970-01-01
    • 1970-01-01
    • 2020-01-01
    • 1970-01-01
    • 2020-03-15
    相关资源
    最近更新 更多