From b1920c1ae6b7563d2678cf4c604861adbb79b401 Mon Sep 17 00:00:00 2001 From: Dave Longley Date: Sun, 15 Sep 2013 00:24:09 -0400 Subject: [PATCH] Use JsonLdExceptions, include JsonLdError codes. --- jsonld.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/jsonld.php b/jsonld.php index 7a97b3d..1c508a7 100644 --- a/jsonld.php +++ b/jsonld.php @@ -325,7 +325,9 @@ function jsonld_default_document_loader($url) { */ function jsonld_default_secure_document_loader($url) { if(strpos($url, 'https') !== 0) { - throw new Exception("Could not GET url: '$url'; 'https' is required."); + throw new JsonLdException( + "Could not GET url: '$url'; 'https' is required.", + 'jsonld.LoadDocumentError', 'loading document failed'); } $redirects = array(); @@ -349,12 +351,15 @@ function jsonld_default_secure_document_loader($url) { })); $result = @file_get_contents($url, false, $stream); if($result === false) { - throw new Exception("Could not GET url: '$url'"); + throw new JsonLdException( + 'Could not retrieve a JSON-LD document from the URL.', + 'jsonld.LoadDocumentError', 'loading document failed'); } foreach($redirects as $redirect) { if(strpos($redirect, 'https') !== 0) { - throw new Exception( - "Could not GET redirected url: '$redirect'; 'https' is required."); + throw new JsonLdException( + "Could not GET redirected url: '$redirect'; 'https' is required.", + 'jsonld.LoadDocumentError', 'loading document failed'); } $url = $redirect; }