From d272cd664d9cb74c72bc07edaad957a39a2bd588 Mon Sep 17 00:00:00 2001 From: p13766 Date: Tue, 29 Jul 2014 18:03:42 +0800 Subject: [PATCH] Update api_media.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit getMedia方法增加对异常处理 --- lib/api_media.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/api_media.js b/lib/api_media.js index a0a4df80..841be999 100644 --- a/lib/api_media.js +++ b/lib/api_media.js @@ -92,7 +92,10 @@ exports.getMedia = function (mediaId, callback) { exports._getMedia = function (mediaId, callback) { var url = this.fileServerPrefix + 'media/get?access_token=' + this.token.accessToken + '&media_id=' + mediaId; urllib.request(url, {}, wrapper(function (err, data, res) { - // 不用处理err,因为wrapper函数处理过 + // handle some err + if (err) { + return callback(err); + } var contentType = res.headers['content-type']; if (contentType === 'application/json') { var ret;