wrap bind with try/catch

This commit is contained in:
Mutasem 2021-11-05 13:23:57 +01:00
parent b02bba55f2
commit 934434eebc

View file

@ -1287,6 +1287,7 @@ export default mixins(
}; };
this.instance.bind('connectionAborted', (connection) => { this.instance.bind('connectionAborted', (connection) => {
try {
if (this.dropPrevented) { if (this.dropPrevented) {
this.dropPrevented = false; this.dropPrevented = false;
return; return;
@ -1305,9 +1306,13 @@ export default mixins(
index: connection.getParameters().index, index: connection.getParameters().index,
eventSource: 'node_connection_drop', eventSource: 'node_connection_drop',
}); });
} catch (e) {
console.error(e);
}
}); });
this.instance.bind('beforeDrop', (info) => { this.instance.bind('beforeDrop', (info) => {
try {
const sourceInfo = info.connection.endpoints[0].getParameters(); const sourceInfo = info.connection.endpoints[0].getParameters();
// @ts-ignore // @ts-ignore
const targetInfo = info.dropEndpoint.getParameters(); const targetInfo = info.dropEndpoint.getParameters();
@ -1322,12 +1327,17 @@ export default mixins(
} }
return true; return true;
} catch (e) {
console.error(e);
return true;
}
}); });
// only one set of visible actions should be visible at the same time // only one set of visible actions should be visible at the same time
let activeConnection: null | Connection = null; let activeConnection: null | Connection = null;
this.instance.bind('connection', (info: OnConnectionBindInfo) => { this.instance.bind('connection', (info: OnConnectionBindInfo) => {
try {
const sourceInfo = info.sourceEndpoint.getParameters(); const sourceInfo = info.sourceEndpoint.getParameters();
const targetInfo = info.targetEndpoint.getParameters(); const targetInfo = info.targetEndpoint.getParameters();
@ -1439,9 +1449,13 @@ export default mixins(
], ],
setStateDirty: true, setStateDirty: true,
}); });
} catch (e) {
console.error(e);
}
}); });
this.instance.bind('connectionMoved', (info) => { this.instance.bind('connectionMoved', (info) => {
try {
// When a connection gets moved from one node to another it for some reason // When a connection gets moved from one node to another it for some reason
// calls the "connection" event but not the "connectionDetached" one. So we listen // calls the "connection" event but not the "connectionDetached" one. So we listen
// additionally to the "connectionMoved" event and then only delete the existing connection. // additionally to the "connectionMoved" event and then only delete the existing connection.
@ -1471,16 +1485,24 @@ export default mixins(
// Make sure to remove the overlay else after the second move // Make sure to remove the overlay else after the second move
// it visibly stays behind free floating without a connection. // it visibly stays behind free floating without a connection.
info.connection.removeOverlays(); info.connection.removeOverlays();
} catch (e) {
console.error(e);
}
}); });
this.instance.bind('connectionDetached', (info) => { this.instance.bind('connectionDetached', (info) => {
try {
CanvasHelpers.resetInputLabelPosition(info.targetEndpoint); CanvasHelpers.resetInputLabelPosition(info.targetEndpoint);
info.connection.removeOverlays(); info.connection.removeOverlays();
this.__removeConnectionByConnectionInfo(info, false); this.__removeConnectionByConnectionInfo(info, false);
} catch (e) {
console.error(e);
}
}); });
// @ts-ignore // @ts-ignore
this.instance.bind('connectionDrag', (connection: Connection) => { this.instance.bind('connectionDrag', (connection: Connection) => {
try {
this.pullConnActive = true; this.pullConnActive = true;
this.newNodeInsertPosition = null; this.newNodeInsertPosition = null;
CanvasHelpers.addOverlays(connection, CanvasHelpers.CONNECTOR_DROP_NODE_OVERLAY); CanvasHelpers.addOverlays(connection, CanvasHelpers.CONNECTOR_DROP_NODE_OVERLAY);
@ -1536,6 +1558,9 @@ export default mixins(
window.addEventListener('mousemove', onMouseMove); window.addEventListener('mousemove', onMouseMove);
window.addEventListener('mouseup', onMouseUp); window.addEventListener('mouseup', onMouseUp);
} catch (e) {
console.error(e);
}
}); });
}, },
async newWorkflow (): Promise<void> { async newWorkflow (): Promise<void> {