【发布时间】:2016-08-23 14:58:11
【问题描述】:
目前我正在使用 Node.js 连接到 Nest Thermostat API。目前,我的应用程序中的所有内容都可以正常工作,除了获取详细的错误消息。
每当我想更改结构时,我都会在 Firebase (_fb) 上调用 _sendUpdate,定义为:
FireBaseRef.prototype._sendUpdate = function(path, targetValue, callback) {
log.i('set ' + path + ' (' + targetValue + ')');
this._fb.child(path).set(targetValue, function(error {
log.e(JSON.stringify(error));
});
}
它使用Firebase.set() 函数。发生错误时,此回调将传递一个错误对象,否则将传递 null,如 here 所述。
作为一个错误示例,我们尝试在 Nest 恒温器设置为 Away 时设置它的温度。根据Nest API guide,应该会看到类似于以下的错误消息
{
"error": "Cannot change target temperature while structure is Away",
"type": "https://developers.nest.com/documentation/cloud/error-messages#structure-in-away-mode",
"message": "Cannot change target temperature while structure is Away",
"instance": "31441a94-ed26-11e4-90ec-1681e6b88ec1",
}
但是,我只是收到 Firebase 警告:
FIREBASE WARNING: set at /devices/thermostats/-GEIJToEG3M9p_jic4J9u7vAgh/target_temperature_c failed: Cannot change target temperature while structure is away
我的日志记录检测到类似的无详细错误:
{
"code":"CANNOT CHANGE TARGET TEMPERATURE WHILE STRUCTURE IS AWAY"
}
谁能解释我如何获得更详细的错误消息?
注意:我使用的是 Firebase API 2.4.2,因为 v3 出现身份验证错误,所以我使用了示例代码中使用的版本 (here)
【问题讨论】:
标签: node.js firebase firebase-realtime-database nest-api