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) => {
try {
if (this.dropPrevented) {
this.dropPrevented = false;
return;
@ -1305,9 +1306,13 @@ export default mixins(
index: connection.getParameters().index,
eventSource: 'node_connection_drop',
});
} catch (e) {
console.error(e);
}
});
this.instance.bind('beforeDrop', (info) => {
try {
const sourceInfo = info.connection.endpoints[0].getParameters();
// @ts-ignore
const targetInfo = info.dropEndpoint.getParameters();
@ -1322,12 +1327,17 @@ export default mixins(
}
return true;
} catch (e) {
console.error(e);
return true;
}
});
// only one set of visible actions should be visible at the same time
let activeConnection: null | Connection = null;
this.instance.bind('connection', (info: OnConnectionBindInfo) => {
try {
const sourceInfo = info.sourceEndpoint.getParameters();
const targetInfo = info.targetEndpoint.getParameters();
@ -1439,9 +1449,13 @@ export default mixins(
],
setStateDirty: true,
});
} catch (e) {
console.error(e);
}
});
this.instance.bind('connectionMoved', (info) => {
try {
// 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
// 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
// it visibly stays behind free floating without a connection.
info.connection.removeOverlays();
} catch (e) {
console.error(e);
}
});
this.instance.bind('connectionDetached', (info) => {
try {
CanvasHelpers.resetInputLabelPosition(info.targetEndpoint);
info.connection.removeOverlays();
this.__removeConnectionByConnectionInfo(info, false);
} catch (e) {
console.error(e);
}
});
// @ts-ignore
this.instance.bind('connectionDrag', (connection: Connection) => {
try {
this.pullConnActive = true;
this.newNodeInsertPosition = null;
CanvasHelpers.addOverlays(connection, CanvasHelpers.CONNECTOR_DROP_NODE_OVERLAY);
@ -1536,6 +1558,9 @@ export default mixins(
window.addEventListener('mousemove', onMouseMove);
window.addEventListener('mouseup', onMouseUp);
} catch (e) {
console.error(e);
}
});
},
async newWorkflow (): Promise<void> {