diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-01-03 20:34:28 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-01-03 20:35:45 -0400 |
commit | 5c48511052b8603b7077780e22f893f4c0160c74 (patch) | |
tree | 3eb449060b2e613949b5d437c544341155180edc /src | |
parent | 9e20be3397fde456ae770cc7d4dfe95cfc2eff3f (diff) |
validators: validateProperties: nest in a cause layer
Diffstat (limited to 'src')
-rw-r--r-- | src/data/things/validators.js | 8 |
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})); } } |