【发布时间】:2018-04-17 19:21:11
【问题描述】:
例如我刚刚收到此错误:
{ Error: There was an error sending your trade offer. We were unable to contact the game's item server. The game's item server may be down or Steam may be experiencing temporary connectivity issues. Please try again later.
at Object.exports.makeAnError (C:\Some\Boring\Route\node_modules\steam-tradeoffer-manager\lib\helpers.js:17:12)
at SteamCommunity.manager._community.httpRequestPost...
如何获得“发送您的交易报价时出错...”部分,以便稍后将其发送回客户?
【问题讨论】:
-
试试 JSON.parse()
-
有点奇怪,你开头有
{。如果是典型的 Error 实例,请使用 @Ryan 的解决方案。如果error.message出于某种原因包含 JSON 并且Error是一个键,则使用JSON.parse(error.message).Error作为@Avihay 建议提取错误 -
@Dmitry:
{的格式来自例如console.log('%o', new Error())
标签: javascript node.js error-handling