Update to latest jsonld.js.
authorDave Longley <dlongley@digitalbazaar.com>
Mon, 03 Mar 2014 16:21:42 -0500
changeset 2134 d7fbcf6ba997
parent 2133 0fa07d98cd8f
child 2135 98606e2bba6b
Update to latest jsonld.js.
playground/jsonld.js
--- a/playground/jsonld.js	Mon Mar 03 16:10:21 2014 -0500
+++ b/playground/jsonld.js	Mon Mar 03 16:21:42 2014 -0500
@@ -1502,6 +1502,16 @@
     var xhr = options.xhr || XMLHttpRequest;
     var req = new xhr();
     req.onload = function(e) {
+      if(req.status >= 400) {
+        return callback(new JsonLdError(
+          'URL could not be dereferenced: ' + req.statusText,
+          'jsonld.LoadDocumentError', {
+            code: 'loading document failed',
+            url: url,
+            httpStatusCode: req.status
+          }), {contextUrl: null, documentUrl: url, document: null});
+      }
+
       var doc = {contextUrl: null, documentUrl: url, document: req.response};
 
       // handle Link Header (avoid unsafe header warning by existence testing)