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:
@@ -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;
|
||||||
|
Reference in New Issue
Block a user