« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/data/things/validators.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/data/things/validators.js b/src/data/things/validators.js
index c15a6cc7..a212b8ae 100644
--- a/src/data/things/validators.js
+++ b/src/data/things/validators.js
@@ -374,9 +374,11 @@ export function validateProperties(spec) {
         const value = object[specKey];
         try {
           specValidator(value);
-        } catch (error) {
-          error.message = `(key: ${colors.green(specKey)}, value: ${inspect(value)}) ${error.message}`;
-          push(error);
+        } catch (caughtError) {
+          const keyPart = colors.green(specKey);
+          const valuePart = inspect(value);
+          const message = `Error for key ${keyPart}: ${valuePart}`;
+          push(new Error(message, {cause: caughtError}));
         }
       }