diff --git a/src/index.js b/src/index.js index 5e40ba4..1bbad72 100644 --- a/src/index.js +++ b/src/index.js @@ -404,13 +404,13 @@ const highlight = false; var refs = {}; var get_ref = function(uri) { - return new Promise( resolve => { + return new Promise( (resolve, reject) => { get_document( uri.clone().hash('').toString() ).then(function(schema){ refs[uri.toString()] = uri.hash() ? jsonpointer.get( schema, uri.hash() ) : schema; }).then(function(){ debug('get_ref'); resolve(); - }); + }, reject); }); }; @@ -543,11 +543,15 @@ const highlight = false; // use the normalized uri parentObject.update( uri.toString() ); - debug(get_ref(uri)); - get_ref( uri ).finally( () => { + var refp = get_ref(uri); + debug(refp); + refp.finally( () => { throttled_render(); resolve(); - }); + }) + // avoid "unhandled rejection" error - the output may be redundant as the + // browser probably already logged the failure, but better be explicit + .catch(e => { console.warn("Unable to resolve $ref " + uri.toString() + ":", e); }); }); }