From e059b8982ea6b1303f664dab861ae0def236e06a Mon Sep 17 00:00:00 2001 From: Aiosa <469130@mail.muni.cz> Date: Thu, 7 Nov 2024 12:22:18 +0100 Subject: [PATCH] Add try-catch for a plugin --- test/demo/filtering-plugin/plugin.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/test/demo/filtering-plugin/plugin.js b/test/demo/filtering-plugin/plugin.js index 3cef71af..b126108a 100644 --- a/test/demo/filtering-plugin/plugin.js +++ b/test/demo/filtering-plugin/plugin.js @@ -70,15 +70,19 @@ debugger; } - const currentIncrement = self.filterIncrement; - for (let i = 0; i < processors.length; i++) { - if (self.filterIncrement !== currentIncrement) { - break; + try { + const currentIncrement = self.filterIncrement; + for (let i = 0; i < processors.length; i++) { + if (self.filterIncrement !== currentIncrement) { + break; + } + await processors[i](contextCopy); } - await processors[i](contextCopy); - } - await tile.setData(contextCopy, 'context2d'); + await tile.setData(contextCopy, 'context2d'); + } catch (e) { + // pass, this is error caused by canvas being destroyed & replaced + } } };