From b1e31b32fe80e7c75ddd3b0aae5b1f350b24baed Mon Sep 17 00:00:00 2001 From: Alexander Corn Date: Wed, 17 Dec 2014 02:04:24 -0500 Subject: [PATCH] Moved checking for Steam Community errors to main SteamCommunity --- classes/CSteamGroup.js | 10 ++++++---- index.js | 10 ++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/classes/CSteamGroup.js b/classes/CSteamGroup.js index cf02563..517fdc3 100644 --- a/classes/CSteamGroup.js +++ b/classes/CSteamGroup.js @@ -18,9 +18,7 @@ SteamCommunity.prototype.getSteamGroup = function(id, callback) { return; } - if(body.match(/

Sorry!<\/h1>/)) { - var match = body.match(/

(.+)<\/h3>/); - callback(match ? match[1] : "Unknown error occurred"); + if(self._checkCommunityError(body, callback)) { return; } @@ -110,6 +108,10 @@ CSteamGroup.prototype.postAnnouncement = function(headline, content, callback) { return; } - // TODO: Handle Community errors + if(self._community._checkCommunityError(body, callback)) { + return; + } + + callback(null); }); }; diff --git a/index.js b/index.js index b7ad936..30c7718 100644 --- a/index.js +++ b/index.js @@ -120,4 +120,14 @@ function generateSessionID() { return Math.floor(Math.random() * 1000000000); }; +SteamCommunity.prototype._checkCommunityError = function(html, callback) { + if(html.match(/

Sorry!<\/h1>/)) { + var match = html.match(/

(.+)<\/h3>/); + callback(match ? match[1] : "Unknown error occurred"); + return true; + } + + return false; +}; + require('./classes/CSteamGroup.js');