Fixes bug where 'database exists' is reported when other couchdb errors are encountered.

This commit is contained in:
Sam Hiatt 2014-09-12 18:50:10 -07:00
parent a0c459aaa0
commit 508e1eec96
1 changed files with 10 additions and 5 deletions

View File

@ -96,12 +96,17 @@ module.exports = function(grunt) {
} else if (err.code && err.description) { // probably connection error } else if (err.code && err.description) { // probably connection error
throw err; throw err;
} }
else if (_this.data.options && _this.data.options.okay_if_exists) { else if (err.error && err.error=="file_exists") {
grunt.log.writeln("Database " + db.name + " exists, skipping"); if (_this.data.options && _this.data.options.okay_if_exists) {
return done(null, null); grunt.log.writeln("Database " + db.name + " exists, skipping");
return done(null, null);
} else {
grunt.warn("Database " + db.name + " exists and okay_if_exists set to false. Aborting.");
throw err;
}
} else { } else {
grunt.warn("Database " + db.name + " exists and okay_if_exists set to false. Aborting."); console.warn("Unrecognized error.");
throw err; throw err
} }
} else if (res && res.ok==true) { } else if (res && res.ok==true) {
grunt.log.ok("Database " + db.name + " created."); grunt.log.ok("Database " + db.name + " created.");