Skip to content

Commit

Permalink
fix: handle one more use case for new users
Browse files Browse the repository at this point in the history
  • Loading branch information
mitulgolakiya committed Apr 12, 2023
1 parent 059a7b8 commit 0de672a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Utils/LaravelEnvatoUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,18 @@ public static function handleEnvatoException($e, $errorData = [])
if ($e->hasResponse()) {
$response = json_decode($e->getResponse()->getBody()->getContents(), true);

if (isset($response['error']) and isset($response['error_description'])) {
throw new EnvatoException($response['error'], $response['error_description'], $e->getCode(), $e, $errorData);
if (!isset($response['error'])) {
throw $e;
}

$error = $response['error'];
$message = $e->getMessage();

if (isset($response['error_description'])) {
$message = $response['error_description'];
}

throw new EnvatoException($error, $message, $e->getCode(), $e, $errorData);
}
}

Expand Down

0 comments on commit 0de672a

Please sign in to comment.