2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-30 22:05:28 +00:00

Format TelegramBotPolling.prototype._getUpdates error on JSON.parse

This commit is contained in:
Yago
2016-03-13 13:43:17 +01:00
parent 178f9cd905
commit 5b93c4a4e1

View File

@@ -3,6 +3,7 @@
var debug = require('debug')('node-telegram-bot-api'); var debug = require('debug')('node-telegram-bot-api');
var Promise = require('bluebird'); var Promise = require('bluebird');
var request = require('request'); var request = require('request');
var util = require('util');
var URL = require('url'); var URL = require('url');
var requestPromise = Promise.promisify(request); var requestPromise = Promise.promisify(request);
@@ -74,7 +75,9 @@ TelegramBotPolling.prototype._getUpdates = function () {
try { try {
data = JSON.parse(resp[0].body); data = JSON.parse(resp[0].body);
} catch (err) { } catch (err) {
throw new Error('Error parsing Telegram response: %s', resp[0].body); var text = util.format('Error parsing Telegram response: %s',
resp[0].body);
throw new Error(text);
} }
if (data.ok) { if (data.ok) {
return data.result; return data.result;