From dfcf5317c10c501c31300642b140f6cd176bcd1a Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Wed, 15 May 2024 19:51:55 +0000 Subject: [PATCH] fix: throwing errors for chameleon blocks (#8121) --- core/insertion_marker_previewer.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/core/insertion_marker_previewer.ts b/core/insertion_marker_previewer.ts index c4038c0c6..3cc9f1a04 100644 --- a/core/insertion_marker_previewer.ts +++ b/core/insertion_marker_previewer.ts @@ -113,13 +113,11 @@ export class InsertionMarkerPreviewer implements IConnectionPreviewer { private previewMarker( draggedConn: RenderedConnection, staticConn: RenderedConnection, - ): RenderedConnection { + ): RenderedConnection | null { const dragged = draggedConn.getSourceBlock(); const marker = this.createInsertionMarker(dragged); const markerConn = this.getMatchingConnection(dragged, marker, draggedConn); - if (!markerConn) { - throw Error('Could not create insertion marker to preview connection'); - } + if (!markerConn) return null; // Render disconnected from everything else so that we have a valid // connection location. @@ -192,7 +190,7 @@ export class InsertionMarkerPreviewer implements IConnectionPreviewer { orig: BlockSvg, marker: BlockSvg, origConn: RenderedConnection, - ) { + ): RenderedConnection | null { const origConns = orig.getConnections_(true); const markerConns = marker.getConnections_(true); if (origConns.length !== markerConns.length) return null;