【问题标题】:Get error message from a throw error NodeJS从抛出错误 NodeJS 中获取错误消息
【发布时间】:2018-06-08 17:53:25
【问题描述】:

我需要在我的数据库中插入一个带有错误的日志错误。

mysql.query(sql_log, [sucess], function (err, result) {
     if (err){ 
        mysql.rollback(function() {
           throw err;
        });
      }
});

我需要获取 err.message

【问题讨论】:

    标签: mysql node.js try-catch getmessage


    【解决方案1】:

    就在 if 条件之后 console.log(err);。

    mysql.query(sql_log, [sucess], function (err, result) {
     if (err){ 
    console.log(err);
        mysql.rollback(function() {
           throw err;
        });
      }});
    

    【讨论】:

    • 是的,我知道,但我需要类似 console.log(err.msg);
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-08
    • 1970-01-01
    相关资源
    最近更新 更多