actually display prefinery error to users

This commit is contained in:
Jeremy Kauffman 2016-07-11 15:47:53 -04:00
parent 07279fc7d0
commit 9a3ad01dc9

View file

@ -172,9 +172,19 @@ class DownloadActions extends Actions
$data = json_decode($body, true);
if (!$data || !isset($data['share_link']))
if (!$data)
{
throw new PrefinerySubscribeException('Missing share_link.');
throw new PrefinerySubscribeException('Received empty response.');
}
else if (isset($data['errors']))
{
throw new PrefinerySubscribeException(implode("\n", array_map(function($error) {
return $error['message'];
}, (array)$data['errors'])));
}
else if (!isset($data['share_link']))
{
throw new PrefinerySubscribeException('Missing share_link');
}
$shareLink = $data['share_link'];