From 8e5e35be0411246cbbc2b2bdc4a93ca6b36b1337 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 12 Jan 2025 20:14:55 -0400 Subject: cacheable-object: tread carefully in {*}PropertyValueError --- src/data/cacheable-object.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/data/cacheable-object.js b/src/data/cacheable-object.js index 010d967a..774e695e 100644 --- a/src/data/cacheable-object.js +++ b/src/data/cacheable-object.js @@ -392,8 +392,22 @@ export class CacheableObjectPropertyValueError extends Error { [Symbol.for('hsmusic.aggregate.translucent')] = true; constructor(property, oldValue, newValue, options) { + let inspectOldValue, inspectNewValue; + + try { + inspectOldValue = inspect(oldValue); + } catch (error) { + inspectOldValue = colors.red(`(couldn't inspect)`); + } + + try { + inspectNewValue = inspect(newValue); + } catch (error) { + inspectNewValue = colors.red(`(couldn't inspect)`); + } + super( - `Error setting ${colors.green(property)} (${inspect(oldValue)} -> ${inspect(newValue)})`, + `Error setting ${colors.green(property)} (${inspectOldValue} -> ${inspectNewValue})`, options); this.property = property; -- cgit 1.3.0-6-gf8a5