Skip to content
This repository was archived by the owner on Feb 12, 2026. It is now read-only.

Commit 7d2e8bc

Browse files
authored
Merge pull request #17 from hyoban/1-27-collect-all-ref-error
fix: collect all missing pointer error
2 parents f830e20 + d0d9b2f commit 7d2e8bc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/pointer.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ class Pointer<S extends object = JSONSchema> {
9292
// Crawl the object, one token at a time
9393
this.value = unwrapOrThrow(obj);
9494

95+
const errors: MissingPointerError[] = [];
96+
9597
for (let i = 0; i < tokens.length; i++) {
9698
if (resolveIf$Ref(this, options, pathFromRoot)) {
9799
// The $ref path has changed, so append the remaining tokens to the path
@@ -120,12 +122,16 @@ class Pointer<S extends object = JSONSchema> {
120122
}
121123

122124
this.value = null;
123-
throw new MissingPointerError(token, decodeURI(this.originalPath));
125+
errors.push(new MissingPointerError(token, decodeURI(this.originalPath)));
124126
} else {
125127
this.value = this.value[token];
126128
}
127129
}
128130

131+
if (errors.length > 0) {
132+
throw errors.length === 1 ? errors[0] : new AggregateError(errors, "Multiple missing pointer errors");
133+
}
134+
129135
// Resolve the final value
130136
if (!this.value || (this.value.$ref && url.resolve(this.path, this.value.$ref) !== pathFromRoot)) {
131137
resolveIf$Ref(this, options, pathFromRoot);

0 commit comments

Comments
 (0)