Better reporting of project-not-found

This commit is contained in:
Nick O'Leary
2018-01-24 21:54:18 +00:00
parent 20a0e4f3e0
commit 95589307cd
6 changed files with 16 additions and 6 deletions

View File

@@ -143,6 +143,7 @@
"projects": {
"changing-project": "Setting active project : __project__",
"active-project": "Active project : __project__",
"project-not-found": "Project not found : __project__",
"no-active-project": "No active project : using default flows file",
"disabled": "Projects disabled : editorTheme.projects.enabled=false",
"disabledNoFlag": "Projects disabled : set editorTheme.projects.enabled=true to enable",

View File

@@ -78,8 +78,12 @@ function loadFlows() {
});
}).catch(function(err) {
activeConfig = null;
events.emit("runtime-event",{id:"runtime-state",payload:{type:"warning",error:err.code,text:"notification.warnings."+err.code},retain:true});
log.warn(log._("nodes.flows.error",{message:err.toString()}));
events.emit("runtime-event",{id:"runtime-state",payload:{type:"warning",error:err.code,project:err.project,text:"notification.warnings."+err.code},retain:true});
if (err.code === "project_not_found") {
log.warn(log._("storage.localfilesystem.projects.project-not-found",{project:err.project}));
} else {
log.warn(log._("nodes.flows.error",{message:err.toString()}));
}
throw err;
});
}

View File

@@ -741,8 +741,9 @@ function checkProjectExists(project) {
var projectPath = fspath.join(projectsDir,project);
return fs.pathExists(projectPath).then(function(exists) {
if (!exists) {
var e = new Error("NLS: project not found");
var e = new Error("Project not found: "+project);
e.code = "project_not_found";
e.project = project;
throw e;
}
});

View File

@@ -437,6 +437,8 @@ function getFlows() {
initialFlowLoadComplete = true;
log.info(log._("storage.localfilesystem.user-dir",{path:settings.userDir}));
if (activeProject) {
// At this point activeProject will be a string, so go load it and
// swap in an instance of Project
return loadProject(activeProject).then(function() {
log.info(log._("storage.localfilesystem.projects.active-project",{project:activeProject.name||"none"}));
log.info(log._("storage.localfilesystem.flows-file",{path:flowsFullPath}));