Skip to content

Commit a5f29b0

Browse files
author
Thibault GRANADA
committed
Add exception API source
1 parent 612d784 commit a5f29b0

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/Exceptions/ApiException.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ class ApiException extends Exception
99
{
1010
protected $response;
1111

12+
/**
13+
* @var string|null Can be used to specify from which API the exception has been thrown.
14+
*/
15+
protected $source;
16+
1217
public function __construct($response, $message = "", $httpCode = 0, Throwable $previous = null)
1318
{
1419
parent::__construct("The request ended on a $httpCode code : $message", $httpCode, $previous);
@@ -38,4 +43,16 @@ public function getApiErrors()
3843
{
3944
return $this->getResponse('errors');
4045
}
46+
47+
public function getSource(): ?string
48+
{
49+
return $this->source;
50+
}
51+
52+
public function setSource(?string $source): self
53+
{
54+
$this->source = $source;
55+
56+
return $this;
57+
}
4158
}

0 commit comments

Comments
 (0)