Skip to content

Commit

Permalink
Add workaround for niivue/niivue#864 which is not yet released
Browse files Browse the repository at this point in the history
  • Loading branch information
jennydaman committed Feb 28, 2024
1 parent 387d799 commit ef58813
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/NiivueMutator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,15 @@ class NiivueMutator {
*/
const setter = this.optionUpdateFunctionMap[key];
if (setter !== undefined) {
setter(value);
try {
setter(value);
} catch (e) {
if (e instanceof Error && e.message === 'this.crosshairs3D is null') {
console.warn('Caught error which was fixed in https://github.com/niivue/niivue/pull/864, please update Niivue.');
} else {
throw e;
}
}
} else if (key in this.nv.opts) {
// @ts-ignore
this.nv.opts[key] = value;
Expand Down
1 change: 0 additions & 1 deletion src/setters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ type OptionUpdateFunctionMap = {
*/
function optionUpdateFunctionMap(nv: Niivue): OptionUpdateFunctionMap {
const mapping = {
// FIXME nv.setCrosshairWidth and nv.setCrosshairColor should NOT be called if nv.crosshairs3D is null!
crosshairWidth: nv.setCrosshairWidth,
crosshairColor: nv.setCrosshairColor,
sliceType: nv.setSliceType,
Expand Down

0 comments on commit ef58813

Please sign in to comment.