Skip to content

Commit

Permalink
Add some debug in exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien committed Nov 28, 2022
1 parent 490a7bc commit 18ef01e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Service/AbstractService.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected function doCall(

$return = $xml->xpath('//return');
if (count($return) && (int) $return[0]->errorCode !== 0) {
$this->parseErrorCodeAndThrow((int) $return[0]->errorCode);
$this->parseErrorCodeAndThrow((int) $return[0]->errorCode, $url, $options);
}

return $this->parseResponse($xml);
Expand Down
11 changes: 9 additions & 2 deletions src/Service/PickupPointByIdService.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,15 @@ public function parseResponse($response): ?PickupPoint
return null;
}

public function parseErrorCodeAndThrow(int $errorCode): void
public function parseErrorCodeAndThrow(int $errorCode, string $url = '', array $options = []): void
{
throw new PickupPointsRequestException(PickupErrorsCodes::ERRORS[$errorCode]);
throw new PickupPointsRequestException(
sprintf(
'%s [DEBUG : url = %s, options = %s]',
PickupErrorsCodes::ERRORS[$errorCode],
$url,
json_encode($options)
)
);
}
}

0 comments on commit 18ef01e

Please sign in to comment.