From 7f2c69e6b0804d662229d02c66a1138f4723a635 Mon Sep 17 00:00:00 2001 From: Jennings Zhang Date: Wed, 28 Feb 2024 16:28:34 -0500 Subject: [PATCH] Broader catch --- src/NiivueMutator.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/NiivueMutator.ts b/src/NiivueMutator.ts index 575bef1..02c695d 100644 --- a/src/NiivueMutator.ts +++ b/src/NiivueMutator.ts @@ -61,13 +61,14 @@ class NiivueMutator { try { setter(value); } catch (e) { - if (!(e instanceof Error)) { + if (!(e instanceof TypeError)) { throw e; } - if ( - e.message === "this.crosshairs3D is null" || - e.message === "Cannot read properties of null (reading 'mm')" - ) { + // check for messages like: + // this.crosshairs3D is null + // Cannot read properties of null (reading 'mm') + // null is not an object (evaluating 'this.crosshairs3D.mm') + if (e.message.includes("null") && (e.message.includes("mm") || e.message.includes("crosshairs3D"))) { console.warn( "Caught error which was fixed in https://github.com/niivue/niivue/pull/864, please update Niivue.", );