Skip to content

Commit 9558930

Browse files
committed
Better reporting of project-not-found
1 parent 20a0e4f commit 9558930

6 files changed

Lines changed: 16 additions & 6 deletions

File tree

editor/js/main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,16 @@
136136
"pull":"Project '"+msg.project+"' reloaded",
137137
"revert": "Project '"+msg.project+"' reloaded"
138138
}[msg.action];
139-
RED.notify(message);
139+
RED.notify("<p>"+message+"</p>");
140140
RED.sidebar.info.refresh()
141141
});
142142
});
143143
return;
144144
}
145145

146146
if (msg.text) {
147-
var text = RED._(msg.text,{default:msg.text});
147+
msg.default = msg.text;
148+
var text = RED._(msg.text,msg);
148149
var options = {
149150
type: msg.type,
150151
fixed: msg.timeout === undefined,

red/api/editor/locales/en-US/editor.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@
9292
"restartRequired": "Node-RED must be restarted to enable upgraded modules",
9393
"credentials_load_failed": "<p>Flows stopped as the credentials could not be decrypted.</p><p>The flow credential file is encrypted, but the project's encryption key is missing or invalid.</p>",
9494
"missing_flow_file": "<p>Project flow file not found.</p><p>The project is not configured with a flow file.</p>",
95-
"project_empty": "<p>The project is empty.</p><p>Do you want to create a default set of project files?<br/>Otherwise, you will have to manually add files to the project outside of the editor.</p>"
95+
"project_empty": "<p>The project is empty.</p><p>Do you want to create a default set of project files?<br/>Otherwise, you will have to manually add files to the project outside of the editor.</p>",
96+
"project_not_found": "<p>Project '__project__' not found.</p>"
9697
},
9798

9899
"error": "<strong>Error</strong>: __message__",

red/runtime/locales/en-US/runtime.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@
143143
"projects": {
144144
"changing-project": "Setting active project : __project__",
145145
"active-project": "Active project : __project__",
146+
"project-not-found": "Project not found : __project__",
146147
"no-active-project": "No active project : using default flows file",
147148
"disabled": "Projects disabled : editorTheme.projects.enabled=false",
148149
"disabledNoFlag": "Projects disabled : set editorTheme.projects.enabled=true to enable",

red/runtime/nodes/flows/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,12 @@ function loadFlows() {
7878
});
7979
}).catch(function(err) {
8080
activeConfig = null;
81-
events.emit("runtime-event",{id:"runtime-state",payload:{type:"warning",error:err.code,text:"notification.warnings."+err.code},retain:true});
82-
log.warn(log._("nodes.flows.error",{message:err.toString()}));
81+
events.emit("runtime-event",{id:"runtime-state",payload:{type:"warning",error:err.code,project:err.project,text:"notification.warnings."+err.code},retain:true});
82+
if (err.code === "project_not_found") {
83+
log.warn(log._("storage.localfilesystem.projects.project-not-found",{project:err.project}));
84+
} else {
85+
log.warn(log._("nodes.flows.error",{message:err.toString()}));
86+
}
8387
throw err;
8488
});
8589
}

red/runtime/storage/localfilesystem/projects/Project.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,8 +741,9 @@ function checkProjectExists(project) {
741741
var projectPath = fspath.join(projectsDir,project);
742742
return fs.pathExists(projectPath).then(function(exists) {
743743
if (!exists) {
744-
var e = new Error("NLS: project not found");
744+
var e = new Error("Project not found: "+project);
745745
e.code = "project_not_found";
746+
e.project = project;
746747
throw e;
747748
}
748749
});

red/runtime/storage/localfilesystem/projects/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,8 @@ function getFlows() {
437437
initialFlowLoadComplete = true;
438438
log.info(log._("storage.localfilesystem.user-dir",{path:settings.userDir}));
439439
if (activeProject) {
440+
// At this point activeProject will be a string, so go load it and
441+
// swap in an instance of Project
440442
return loadProject(activeProject).then(function() {
441443
log.info(log._("storage.localfilesystem.projects.active-project",{project:activeProject.name||"none"}));
442444
log.info(log._("storage.localfilesystem.flows-file",{path:flowsFullPath}));

0 commit comments

Comments
 (0)