diff --git a/src/Traits/HasResponse.php b/src/Traits/HasResponse.php index b7a3b596..eb319392 100644 --- a/src/Traits/HasResponse.php +++ b/src/Traits/HasResponse.php @@ -4,6 +4,7 @@ use Mollie\Api\Http\PendingRequest; use Mollie\Api\Http\Response; +use Mollie\Api\Exceptions\MollieException; trait HasResponse { @@ -23,8 +24,10 @@ public function setResponse(?Response $response): self public function getPendingRequest(): PendingRequest { - return $this->response - ? $this->response->getPendingRequest() - : throw new \Exception('Response is not set'); + if (! $this->response) { + throw new MollieException('Response is not set'); + } + + return $this->response->getPendingRequest(); } }