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

Improve error reporting when installing bad nodes

This commit is contained in:
Nick O'Leary 2021-09-30 15:28:09 +01:00
parent ec27e19e3f
commit 29e903e1c8
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
3 changed files with 32 additions and 11 deletions

View File

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

View File

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

View File

@ -299,16 +299,29 @@ async function installModule(module,version,url) {
function reportAddedModules(info) {
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 j=0;j<info.nodes[i].types.length;j++) {
log.info(" - "+
(info.nodes[i].module?info.nodes[i].module+":":"")+
info.nodes[i].types[j]+
(info.nodes[i].err?" : "+info.nodes[i].err:"")
);
const typeCount = info.nodes[i].types.length;
if (typeCount > 0) {
for (var j=0;j<typeCount;j++) {
installedTypes.push(" - "+
(info.nodes[i].module?info.nodes[i].module+":":"")+
info.nodes[i].types[j]+
(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;
}