Skip to content

Commit

Permalink
Merge pull request #34 from CristalTeam/feature/exception_source
Browse files Browse the repository at this point in the history
Add exception source & fix debugbar decorator
  • Loading branch information
ffouchier authored Mar 18, 2022
2 parents ff05dd3 + a5f29b0 commit 4065184
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,6 @@ public static function formatDuration($seconds)

public function getResponseHeaders(): array
{
$this->transport->getResponseHeaders();
return $this->transport->getResponseHeaders();
}
}
17 changes: 17 additions & 0 deletions src/Exceptions/ApiException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ class ApiException extends Exception
{
protected $response;

/**
* @var string|null Can be used to specify from which API the exception has been thrown.
*/
protected $source;

public function __construct($response, $message = "", $httpCode = 0, Throwable $previous = null)
{
parent::__construct("The request ended on a $httpCode code : $message", $httpCode, $previous);
Expand Down Expand Up @@ -38,4 +43,16 @@ public function getApiErrors()
{
return $this->getResponse('errors');
}

public function getSource(): ?string
{
return $this->source;
}

public function setSource(?string $source): self
{
$this->source = $source;

return $this;
}
}

0 comments on commit 4065184

Please sign in to comment.