1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge pull request #3158 from node-red/node-install-err-reporting

Improve node install error reporting
This commit is contained in:
Nick O'Leary 2021-10-04 10:55:47 +01:00 committed by GitHub
commit f8ee92ba06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 11 deletions

View File

@ -544,7 +544,8 @@
"nodeEnabled_plural": "Nodes enabled:", "nodeEnabled_plural": "Nodes enabled:",
"nodeDisabled": "Node disabled:", "nodeDisabled": "Node disabled:",
"nodeDisabled_plural": "Nodes disabled:", "nodeDisabled_plural": "Nodes disabled:",
"nodeUpgraded": "Node module __module__ upgraded to version __version__" "nodeUpgraded": "Node module __module__ upgraded to version __version__",
"unknownNodeRegistered": "Error loading node: <ul><li>__type__<br>__error__</li></ul>"
}, },
"editor": { "editor": {
"title": "Manage palette", "title": "Manage palette",

View File

@ -142,9 +142,21 @@ RED.nodes = (function() {
RED.events.emit("registry:node-set-disabled",ns); RED.events.emit("registry:node-set-disabled",ns);
}, },
registerNodeType: function(nt,def) { registerNodeType: function(nt,def) {
nodeDefinitions[nt] = def;
def.type = nt;
if (nt.substring(0,8) != "subflow:") { if (nt.substring(0,8) != "subflow:") {
if (!nodeSets[typeToId[nt]]) {
var error = "";
var fullType = nt;
if (RED._loadingModule) {
fullType = "["+RED._loadingModule+"] "+nt;
if (nodeSets[RED._loadingModule]) {
error = nodeSets[RED._loadingModule].err || "";
} else {
error = "Unknown error";
}
}
RED.notify(RED._("palette.event.unknownNodeRegistered",{type:fullType, error:error}), "error");
return;
}
def.set = nodeSets[typeToId[nt]]; def.set = nodeSets[typeToId[nt]];
nodeSets[typeToId[nt]].added = true; nodeSets[typeToId[nt]].added = true;
nodeSets[typeToId[nt]].enabled = true; nodeSets[typeToId[nt]].enabled = true;
@ -167,9 +179,13 @@ RED.nodes = (function() {
} }
return result; return result;
} }
// TODO: too tightly coupled into palette UI // TODO: too tightly coupled into palette UI
} }
def.type = nt;
nodeDefinitions[nt] = def;
if (def.defaults) { if (def.defaults) {
for (var d in def.defaults) { for (var d in def.defaults) {
if (def.defaults.hasOwnProperty(d)) { if (def.defaults.hasOwnProperty(d)) {

View File

@ -299,15 +299,28 @@ async function installModule(module,version,url) {
function reportAddedModules(info) { function reportAddedModules(info) {
if (info.nodes.length > 0) { if (info.nodes.length > 0) {
log.info(log._("server.added-types")); const installedTypes = [];
const errorSets = [];
for (var i=0;i<info.nodes.length;i++) { for (var i=0;i<info.nodes.length;i++) {
for (var j=0;j<info.nodes[i].types.length;j++) { const typeCount = info.nodes[i].types.length;
log.info(" - "+ if (typeCount > 0) {
for (var j=0;j<typeCount;j++) {
installedTypes.push(" - "+
(info.nodes[i].module?info.nodes[i].module+":":"")+ (info.nodes[i].module?info.nodes[i].module+":":"")+
info.nodes[i].types[j]+ info.nodes[i].types[j]+
(info.nodes[i].err?" : "+info.nodes[i].err:"") (info.nodes[i].err?" : "+info.nodes[i].err:"")
); );
} }
} else if (info.nodes[i].err) {
errorSets.push(`[${info.nodes[i].id}] ${info.nodes[i].err}`)
}
}
if (errorSets.length > 0) {
errorSets.forEach(l => log.warn(l))
}
if (installedTypes.length > 0) {
log.info(log._("server.added-types"));
installedTypes.forEach(l => log.info(l))
} }
} }
return info; return info;