Skip to content

Add path information to errors #163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/dereference.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,13 @@ function dereference$Ref ($ref, path, pathFromRoot, parents, $refs, options) {
// console.log('Dereferencing $ref pointer "%s" at %s', $ref.$ref, path);

let $refPath = url.resolve(path, $ref.$ref);
let pointer = $refs._resolve($refPath, options);
let pointer;

try {
pointer = $refs._resolve($refPath, options);
} catch (e) {
throw ono(e, { path, originalPath: $ref.$ref });
}

// Check for circular references
let directCircular = pointer.circular;
Expand Down
11 changes: 9 additions & 2 deletions lib/resolve-external.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const $Ref = require("./ref");
const Pointer = require("./pointer");
const parse = require("./parse");
const url = require("./util/url");
const { ono } = require("ono");

module.exports = resolveExternal;

Expand Down Expand Up @@ -100,8 +101,14 @@ async function resolve$Ref ($ref, path, $refs, options) {
return Promise.resolve($ref.value);
}

// Parse the $referenced file/url
const result = await parse(resolvedPath, $refs, options);
let result;

try {
// Parse the $referenced file/url
result = await parse(resolvedPath, $refs, options);
} catch (e) {
throw ono(e, { path: resolvedPath });
}

// Crawl the parsed value
// console.log('Resolving $ref pointers in %s', withoutHash);
Expand Down