From 5b93c4a4e18399aefb9b1e263be69762d8680981 Mon Sep 17 00:00:00 2001 From: Yago Date: Sun, 13 Mar 2016 13:43:17 +0100 Subject: [PATCH] Format TelegramBotPolling.prototype._getUpdates error on JSON.parse --- src/telegramPolling.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/telegramPolling.js b/src/telegramPolling.js index d0546e6..a5da59f 100644 --- a/src/telegramPolling.js +++ b/src/telegramPolling.js @@ -3,6 +3,7 @@ var debug = require('debug')('node-telegram-bot-api'); var Promise = require('bluebird'); var request = require('request'); +var util = require('util'); var URL = require('url'); var requestPromise = Promise.promisify(request); @@ -74,7 +75,9 @@ TelegramBotPolling.prototype._getUpdates = function () { try { data = JSON.parse(resp[0].body); } 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) { return data.result;