Permalink
Browse files

[minor] more resiliant to the various errors nodejitsu-clouddb can throw

  • Loading branch information...
1 parent c157adf commit 35f9d934054954ea986d84f338629a5c2d8c2d66 nicoreed committed Jul 13, 2011
Showing with 7 additions and 5 deletions.
  1. +1 −1 lib/jitsu/api/databases.js
  2. +6 −4 lib/jitsu/commands/databases.js
@@ -31,7 +31,7 @@ util.inherits(Databases, jitsu.api.Client);
//
Databases.prototype.create = function (databaseType, databaseName, callback) {
this.request('POST', ['databases', this.options.get('username'), databaseName], {type:databaseType}, callback, function (res, result) {
- callback(null, result);
+ callback(null, result, res);
});
};
@@ -40,13 +40,15 @@ databases.create = function (databaseType, databaseName, callback) {
return callback();
}
- jitsu.databases.create(databaseType, databaseName, function (err) {
- if (err) {
- if (err.statusCode === '409' ) {
+ jitsu.databases.create(databaseType, databaseName, function (err, a, res) {
+ if (err || res.statusCode >= 400) {
+ if ( err && err.statusCode === '409' ) {
winston.error('You already created a database with that name.');
}
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);
}
}

0 comments on commit 35f9d93

Please sign in to comment.