Skip to content

Commit

Permalink
Merge pull request #2 from MikeBazhenov/master
Browse files Browse the repository at this point in the history
Вынесен callback за try catch
  • Loading branch information
toporchillo committed May 22, 2014
2 parents 3cde861 + 8fae638 commit 38c76f9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.js
Expand Up @@ -58,11 +58,11 @@ exports.ApiQuery = function ApiQuery(token, key, query, cb) {
}
try {
var ret = JSON.parse(data);
cb(null, ret);
}
catch (err) {
cb(new Error('Сервис вернул неверный ответ, ожидался JSON', 'APIError'));
return cb(new Error('Сервис вернул неверный ответ, ожидался JSON', 'APIError'));
}
cb(null, ret);
})
});

Expand All @@ -73,4 +73,4 @@ exports.ApiQuery = function ApiQuery(token, key, query, cb) {
req.write('data\n');
req.write('data\n');
req.end();
}
}

0 comments on commit 38c76f9

Please sign in to comment.