mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-08-07 23:03:00 +03:00
Merge pull request #4317 from devdot/http-fetch-improve-exception-logging
Modify HttpFetchException flow to log the exception
This commit is contained in:
@@ -29,7 +29,8 @@ class HttpFetcher
|
||||
curl_close($ch);
|
||||
|
||||
if ($err) {
|
||||
throw new HttpFetchException($err);
|
||||
$errno = curl_errno($ch);
|
||||
throw new HttpFetchException($err, $errno);
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
@@ -34,7 +34,7 @@ class UserAvatars
|
||||
$user->avatar()->associate($avatar);
|
||||
$user->save();
|
||||
} catch (Exception $e) {
|
||||
Log::error('Failed to save user avatar image');
|
||||
Log::error('Failed to save user avatar image', ['exception' => $e]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class UserAvatars
|
||||
$user->avatar()->associate($avatar);
|
||||
$user->save();
|
||||
} catch (Exception $e) {
|
||||
Log::error('Failed to save user avatar image');
|
||||
Log::error('Failed to save user avatar image', ['exception' => $e]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,14 +107,14 @@ class UserAvatars
|
||||
/**
|
||||
* Gets an image from url and returns it as a string of image data.
|
||||
*
|
||||
* @throws Exception
|
||||
* @throws HttpFetchException
|
||||
*/
|
||||
protected function getAvatarImageData(string $url): string
|
||||
{
|
||||
try {
|
||||
$imageData = $this->http->fetch($url);
|
||||
} catch (HttpFetchException $exception) {
|
||||
throw new Exception(trans('errors.cannot_get_image_from_url', ['url' => $url]));
|
||||
throw new HttpFetchException(trans('errors.cannot_get_image_from_url', ['url' => $url]), $exception->getCode(), $exception);
|
||||
}
|
||||
|
||||
return $imageData;
|
||||
|
Reference in New Issue
Block a user