mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add error handling to all node definition api calls
This commit is contained in:
parent
3959fcdc88
commit
0300458ba8
@ -399,7 +399,11 @@ RED.editor = (function() {
|
|||||||
}
|
}
|
||||||
var completePrepare = function() {
|
var completePrepare = function() {
|
||||||
if (definition.oneditprepare) {
|
if (definition.oneditprepare) {
|
||||||
|
try {
|
||||||
definition.oneditprepare.call(node);
|
definition.oneditprepare.call(node);
|
||||||
|
} catch(err) {
|
||||||
|
console.log("oneditprepare",node.id,node.type,err.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Now invoke any change handlers added to the fields - passing true
|
// Now invoke any change handlers added to the fields - passing true
|
||||||
// to prevent full node validation from being triggered each time
|
// to prevent full node validation from being triggered each time
|
||||||
@ -485,7 +489,11 @@ RED.editor = (function() {
|
|||||||
click: function() {
|
click: function() {
|
||||||
if (editing_node._def) {
|
if (editing_node._def) {
|
||||||
if (editing_node._def.oneditcancel) {
|
if (editing_node._def.oneditcancel) {
|
||||||
|
try {
|
||||||
editing_node._def.oneditcancel.call(editing_node);
|
editing_node._def.oneditcancel.call(editing_node);
|
||||||
|
} catch(err) {
|
||||||
|
console.log("oneditcancel",editing_node.id,editing_node.type,err.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var d in editing_node._def.defaults) {
|
for (var d in editing_node._def.defaults) {
|
||||||
@ -532,10 +540,14 @@ RED.editor = (function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
var rc = editing_node._def.oneditsave.call(editing_node);
|
var rc = editing_node._def.oneditsave.call(editing_node);
|
||||||
if (rc === true) {
|
if (rc === true) {
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
} catch(err) {
|
||||||
|
console.log("oneditsave",editing_node.id,editing_node.type,err.toString());
|
||||||
|
}
|
||||||
|
|
||||||
for (d in editing_node._def.defaults) {
|
for (d in editing_node._def.defaults) {
|
||||||
if (editing_node._def.defaults.hasOwnProperty(d)) {
|
if (editing_node._def.defaults.hasOwnProperty(d)) {
|
||||||
@ -647,7 +659,11 @@ RED.editor = (function() {
|
|||||||
editTrayWidthCache[type] = dimensions.width;
|
editTrayWidthCache[type] = dimensions.width;
|
||||||
if (editing_node && editing_node._def.oneditresize) {
|
if (editing_node && editing_node._def.oneditresize) {
|
||||||
var form = $("#dialog-form");
|
var form = $("#dialog-form");
|
||||||
|
try {
|
||||||
editing_node._def.oneditresize.call(editing_node,{width:form.width(),height:form.height()});
|
editing_node._def.oneditresize.call(editing_node,{width:form.width(),height:form.height()});
|
||||||
|
} catch(err) {
|
||||||
|
console.log("oneditresize",editing_node.id,editing_node.type,err.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
open: function(tray) {
|
open: function(tray) {
|
||||||
@ -763,7 +779,11 @@ RED.editor = (function() {
|
|||||||
resize: function() {
|
resize: function() {
|
||||||
if (editing_config_node && editing_config_node._def.oneditresize) {
|
if (editing_config_node && editing_config_node._def.oneditresize) {
|
||||||
var form = $("#node-config-dialog-edit-form");
|
var form = $("#node-config-dialog-edit-form");
|
||||||
|
try {
|
||||||
editing_config_node._def.oneditresize.call(editing_config_node,{width:form.width(),height:form.height()});
|
editing_config_node._def.oneditresize.call(editing_config_node,{width:form.width(),height:form.height()});
|
||||||
|
} catch(err) {
|
||||||
|
console.log("oneditresize",editing_node.id,editing_node.type,err.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
open: function(tray) {
|
open: function(tray) {
|
||||||
@ -867,9 +887,17 @@ RED.editor = (function() {
|
|||||||
if (configTypeDef.oneditcancel) {
|
if (configTypeDef.oneditcancel) {
|
||||||
var cn = RED.nodes.node(configId);
|
var cn = RED.nodes.node(configId);
|
||||||
if (cn) {
|
if (cn) {
|
||||||
|
try {
|
||||||
configTypeDef.oneditcancel.call(cn,false);
|
configTypeDef.oneditcancel.call(cn,false);
|
||||||
|
} catch(err) {
|
||||||
|
console.log("oneditcancel",cn.id,cn.type,err.toString());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
try {
|
||||||
configTypeDef.oneditcancel.call({id:configId},true);
|
configTypeDef.oneditcancel.call({id:configId},true);
|
||||||
|
} catch(err) {
|
||||||
|
console.log("oneditcancel",configId,configType,err.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -891,7 +919,11 @@ RED.editor = (function() {
|
|||||||
var scope = $("#node-config-dialog-scope").val();
|
var scope = $("#node-config-dialog-scope").val();
|
||||||
|
|
||||||
if (configTypeDef.oneditsave) {
|
if (configTypeDef.oneditsave) {
|
||||||
|
try {
|
||||||
configTypeDef.oneditsave.call(editing_config_node);
|
configTypeDef.oneditsave.call(editing_config_node);
|
||||||
|
} catch(err) {
|
||||||
|
console.log("oneditsave",editing_config_node.id,editing_config_node.type,err.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (d in configTypeDef.defaults) {
|
for (d in configTypeDef.defaults) {
|
||||||
@ -994,12 +1026,20 @@ RED.editor = (function() {
|
|||||||
var configType = type;
|
var configType = type;
|
||||||
var configTypeDef = RED.nodes.getType(configType);
|
var configTypeDef = RED.nodes.getType(configType);
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
if (configTypeDef.ondelete) {
|
if (configTypeDef.ondelete) {
|
||||||
|
// Deprecated: never documented but used by some early nodes
|
||||||
|
console.log("Deprecated API warning: config node type ",configType," has an ondelete function - should be oneditdelete");
|
||||||
configTypeDef.ondelete.call(editing_config_node);
|
configTypeDef.ondelete.call(editing_config_node);
|
||||||
}
|
}
|
||||||
if (configTypeDef.oneditdelete) {
|
if (configTypeDef.oneditdelete) {
|
||||||
configTypeDef.oneditdelete.call(editing_config_node);
|
configTypeDef.oneditdelete.call(editing_config_node);
|
||||||
}
|
}
|
||||||
|
} catch(err) {
|
||||||
|
console.log("oneditdelete",editing_config_node.id,editing_config_node.type,err.toString());
|
||||||
|
}
|
||||||
|
|
||||||
var historyEvent = {
|
var historyEvent = {
|
||||||
t:'delete',
|
t:'delete',
|
||||||
nodes:[editing_config_node],
|
nodes:[editing_config_node],
|
||||||
|
Loading…
Reference in New Issue
Block a user