Skip to content

Commit

Permalink
Merge pull request #5 from microsoft/fix/exceptions
Browse files Browse the repository at this point in the history
Add raw response to API exception
  • Loading branch information
SilasKenneth authored Oct 24, 2022
2 parents f9e71b9 + 0c61167 commit 4ab179f
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/ApiException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@

namespace Microsoft\Kiota\Abstractions;
use Exception;
use Psr\Http\Message\ResponseInterface;

class ApiException extends Exception
{
/**
* Raw response object
*
* @var ResponseInterface|null
*/
private ?ResponseInterface $response = null;

/**
* @param string $message
* @param int $code
Expand All @@ -13,4 +21,25 @@ class ApiException extends Exception
public function __construct(string $message = "", int $code = 0, ?Exception $innerException = null) {
parent::__construct($message, $code, $innerException);
}
}

/**
* Set raw response from API
*
* @param ResponseInterface $response
* @return void
*/
public function setResponse(ResponseInterface $response): void
{
$this->response = $response;
}

/**
* Return raw response from API
*
* @return ResponseInterface|null
*/
public function getResponse(): ?ResponseInterface
{
return $this->response;
}
}

0 comments on commit 4ab179f

Please sign in to comment.