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,13 +96,18 @@ module.exports = function(grunt) {
} else if (err.code && err.description) { // probably connection error
throw err;
}
else if (_this.data.options && _this.data.options.okay_if_exists) {
else if (err.error && err.error=="file_exists") {
if (_this.data.options && _this.data.options.okay_if_exists) {
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 {
console.warn("Unrecognized error.");
throw err
}
} else if (res && res.ok==true) {
grunt.log.ok("Database " + db.name + " created.");
return done(null, null);