mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Better error handling/reporting in project creation
This commit is contained in:
@@ -248,8 +248,11 @@ module.exports = {
|
||||
res.redirect(303,req.baseUrl+"/"+projectName+"/status");
|
||||
})
|
||||
.catch(function(err) {
|
||||
console.log(err.stack);
|
||||
res.status(400).json({error:"unexpected_error", message:err.toString()});
|
||||
if (err.code) {
|
||||
res.status(400).json({error:err.code, message: err.message});
|
||||
} else {
|
||||
res.status(400).json({error:"unexpected_error", message:err.toString()});
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
|
@@ -912,40 +912,17 @@ function createProject(user, metadata) {
|
||||
);
|
||||
auth = authCache.get(project,originRemote.url,username);
|
||||
}
|
||||
return gitTools.clone(originRemote,auth,projectPath).then(function(result) {
|
||||
// Check this is a valid project
|
||||
// If it is empty
|
||||
// - if 'populate' flag is set, call populateProject
|
||||
// - otherwise reject with suitable error to allow UI to confirm population
|
||||
// If it is missing package.json/flow.json/flow_cred.json
|
||||
// - reject as invalid project
|
||||
|
||||
// checkProjectFiles(project).then(function(results) {
|
||||
// console.log("checkProjectFiles");
|
||||
// console.log(results);
|
||||
// });
|
||||
// return gitTools.getFiles(projectPath).then(function() {
|
||||
// // It wasn't an empty repository.
|
||||
// // TODO: check for required files - checkProjectFiles
|
||||
//
|
||||
// }).catch(function(err) {
|
||||
// if (/ambiguous argument/.test(err.message)) {
|
||||
// // Empty repository
|
||||
// err.code = "project_empty";
|
||||
// err.message = "Project is empty";
|
||||
// }
|
||||
// throw err;
|
||||
// });
|
||||
resolve(getProject(project));
|
||||
}).catch(function(error) {
|
||||
fs.remove(projectPath,function() {
|
||||
reject(error);
|
||||
});
|
||||
})
|
||||
return gitTools.clone(originRemote,auth,projectPath);
|
||||
} else {
|
||||
createDefaultProject(user, metadata).then(function() { resolve(getProject(project))}).catch(reject);
|
||||
return createDefaultProject(user, metadata);
|
||||
}
|
||||
}).catch(reject);
|
||||
}).then(function() {
|
||||
resolve(getProject(project))
|
||||
}).catch(function(err) {
|
||||
fs.remove(projectPath,function() {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@@ -73,6 +73,10 @@ function runGitCommand(args,cwd,env) {
|
||||
err.code = "git_repository_not_found";
|
||||
} else if (/refusing to merge unrelated histories/.test(stderr)) {
|
||||
err.code = "git_pull_unrelated_history"
|
||||
} else if (/Please tell me who you are/.test(stderr)) {
|
||||
err.code = "git_missing_user";
|
||||
} else if (/name consists only of disallowed characters/.test(stderr)) {
|
||||
err.code = "git_missing_user";
|
||||
}
|
||||
return reject(err);
|
||||
}
|
||||
|
Reference in New Issue
Block a user