Skip to content

Commit

Permalink
fix: WrapperError should be an actual error
Browse files Browse the repository at this point in the history
  • Loading branch information
nzakas committed Jan 10, 2024
1 parent 2f248eb commit 2523f01
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/object-schema.js
Expand Up @@ -112,22 +112,22 @@ class MissingDependentKeysError extends Error {
/**
* Wrapper error for errors occuring during a merge or validate operation.
*/
class WrapperError {
class WrapperError extends Error {

/**
* Creates a new instance.
* @param {string} key The object key causing the error.
* @param {Error} source The source error.
*/
constructor(key, source) {
return Object.create(source, {
message: {
value: `Key "${key}": ` + source.message,
configurable: true,
writable: true,
enumerable: true
super(`Key "${key}": ${source.message}`, { cause: source });

// copy over custom properties that aren't represented
for (const key of Object.keys(source)) {
if (!(key in this)) {
this[key] = source[key];
}
});
}
}
}

Expand Down

0 comments on commit 2523f01

Please sign in to comment.