« get me outta code hell

cacheable-object: tread carefully in {*}PropertyValueError - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2025-01-12 20:14:55 -0400
committer(quasar) nebula <qznebula@protonmail.com>2025-01-13 16:43:08 -0400
commit8e5e35be0411246cbbc2b2bdc4a93ca6b36b1337 (patch)
tree577c4ee31b23f333927f631756d500ccf365ed1c /src/data
parent9ab0f503d6d57b7476041fc891ae3b0760df75a3 (diff)
cacheable-object: tread carefully in {*}PropertyValueError
Diffstat (limited to 'src/data')
-rw-r--r--src/data/cacheable-object.js16
1 files changed, 15 insertions, 1 deletions
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;