Moved checking for Steam Community errors to main SteamCommunity

This commit is contained in:
Alexander Corn 2014-12-17 02:04:24 -05:00
parent 0f16f11668
commit b1e31b32fe
2 changed files with 16 additions and 4 deletions

View File

@ -18,9 +18,7 @@ SteamCommunity.prototype.getSteamGroup = function(id, callback) {
return;
}
if(body.match(/<h1>Sorry!<\/h1>/)) {
var match = body.match(/<h3>(.+)<\/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);
});
};

View File

@ -120,4 +120,14 @@ function generateSessionID() {
return Math.floor(Math.random() * 1000000000);
};
SteamCommunity.prototype._checkCommunityError = function(html, callback) {
if(html.match(/<h1>Sorry!<\/h1>/)) {
var match = html.match(/<h3>(.+)<\/h3>/);
callback(match ? match[1] : "Unknown error occurred");
return true;
}
return false;
};
require('./classes/CSteamGroup.js');