Skip to content

Commit

Permalink
Print warning when unable to resolve instance location
Browse files Browse the repository at this point in the history
  • Loading branch information
jirutka committed Jun 25, 2024
1 parent acafb2b commit 7978b6e
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/commands/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,18 @@ function withInstanceLocation<T extends ValidationError>(
errors: T[],
file: ParsedFile,
): Required<T, 'instanceLocation'>[] {
return errors.map(err => ({
...err,
instanceLocation: {
filename: file.filename,
...file.locate(err.instancePath.split('/').slice(1).map(unescapeJsonPointer)),
},
}))
return errors.map(err => {
const location = file.locate(err.instancePath.split('/').slice(1).map(unescapeJsonPointer))
if (!location) {
// This shouldn't happen...
console.warn(`Warning: Unable to resolve instance location: ${err.instancePath}`)
}
return {
...err,
instanceLocation: {
filename: file.filename,
...location,
},
}
})
}

0 comments on commit 7978b6e

Please sign in to comment.