forked from friendica/php-json-ld
Use JsonLdExceptions, include JsonLdError codes.
This commit is contained in:
parent
f84cf6c2fc
commit
b1920c1ae6
13
jsonld.php
13
jsonld.php
|
@ -325,7 +325,9 @@ function jsonld_default_document_loader($url) {
|
||||||
*/
|
*/
|
||||||
function jsonld_default_secure_document_loader($url) {
|
function jsonld_default_secure_document_loader($url) {
|
||||||
if(strpos($url, 'https') !== 0) {
|
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();
|
$redirects = array();
|
||||||
|
@ -349,12 +351,15 @@ function jsonld_default_secure_document_loader($url) {
|
||||||
}));
|
}));
|
||||||
$result = @file_get_contents($url, false, $stream);
|
$result = @file_get_contents($url, false, $stream);
|
||||||
if($result === false) {
|
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) {
|
foreach($redirects as $redirect) {
|
||||||
if(strpos($redirect, 'https') !== 0) {
|
if(strpos($redirect, 'https') !== 0) {
|
||||||
throw new Exception(
|
throw new JsonLdException(
|
||||||
"Could not GET redirected url: '$redirect'; 'https' is required.");
|
"Could not GET redirected url: '$redirect'; 'https' is required.",
|
||||||
|
'jsonld.LoadDocumentError', 'loading document failed');
|
||||||
}
|
}
|
||||||
$url = $redirect;
|
$url = $redirect;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue