Skip to content

Commit

Permalink
Response - better print errors
Browse files Browse the repository at this point in the history
  • Loading branch information
pekral committed Oct 13, 2020
1 parent 93218b0 commit e46d833
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Http/ResponseHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,19 @@ public function __construct(Config $config)
public function convertResponseToEvidenceResults(Response $response): array
{
$data = $response->getData();
$hasErrors = isset($data[0], $data[0]['errors']);

if (isset($data['success']) && $data['success'] === 'false') {
throw new EcomailFlexibeeRequestFail($data['message']);
if ($hasErrors || (isset($data['success']) && $data['success'] === 'false')) {

if ($hasErrors && !isset($data['message'])) {
$data['message'] = '';

foreach ($data[0]['errors'] as $errors) {
$data['message'] .= "\n" . $errors['message'];
}
}

throw new EcomailFlexibeeRequestFail($data['message'], $response->getStatusCode());
}

if (!isset($data[$this->config->getEvidence()])) {
Expand Down

0 comments on commit e46d833

Please sign in to comment.