HFP-3095 Throw error if retrieving content from hub failed

content-hub
Thomas Marstrander 2020-09-09 14:48:19 +02:00
parent 917a9b6ccb
commit 14bad68d70
No known key found for this signature in database
GPG Key ID: 59D7F1EC8B90E9A6
1 changed files with 4 additions and 0 deletions

View File

@ -3739,6 +3739,10 @@ class H5PCore {
throw new Exception($this->h5pF->t('Unable to authorize with the H5P Hub. Please check your Hub registration and connection.')); throw new Exception($this->h5pF->t('Unable to authorize with the H5P Hub. Please check your Hub registration and connection.'));
} }
if (isset($response['status']) && $response['status'] !== 200) {
throw new Exception($this->h5pF->t('Connecting to the content hub failed, please try again later.'));
}
$hub_content = json_decode($response['data'])->data; $hub_content = json_decode($response['data'])->data;
$hub_content->id = "$hub_content->id"; $hub_content->id = "$hub_content->id";
return $hub_content; return $hub_content;