Skip to content

Commit

Permalink
[minor] more resiliant to the various errors nodejitsu-clouddb can throw
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoreed committed Jul 13, 2011
1 parent c157adf commit 35f9d93
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/jitsu/api/databases.js
Expand Up @@ -31,7 +31,7 @@ util.inherits(Databases, jitsu.api.Client);
// //
Databases.prototype.create = function (databaseType, databaseName, callback) { Databases.prototype.create = function (databaseType, databaseName, callback) {
this.request('POST', ['databases', this.options.get('username'), databaseName], {type:databaseType}, callback, function (res, result) { this.request('POST', ['databases', this.options.get('username'), databaseName], {type:databaseType}, callback, function (res, result) {
callback(null, result); callback(null, result, res);
}); });
}; };


Expand Down
10 changes: 6 additions & 4 deletions lib/jitsu/commands/databases.js
Expand Up @@ -40,13 +40,15 @@ databases.create = function (databaseType, databaseName, callback) {
return callback(); return callback();
} }


jitsu.databases.create(databaseType, databaseName, function (err) { jitsu.databases.create(databaseType, databaseName, function (err, a, res) {
if (err) { if (err || res.statusCode >= 400) {
if (err.statusCode === '409' ) { if ( err && err.statusCode === '409' ) {
winston.error('You already created a database with that name.'); winston.error('You already created a database with that name.');
} }
else { else {
winston.error(err); winston.error('Database could not be created.');
winston.error(err || ('Unknown error code: ' + res.statusCode));
winston.error('Try again and if it fails again, contact nodejitsu.');
return callback(err); return callback(err);
} }
} }
Expand Down

0 comments on commit 35f9d93

Please sign in to comment.