Skip to content

Commit

Permalink
Merge pull request #34 from microsoft/fix/api-exception
Browse files Browse the repository at this point in the history
Add response status code to API exception
  • Loading branch information
Ndiritu authored Feb 10, 2023
2 parents 614b0c0 + 8cf3f03 commit 59dd728
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/ApiException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

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

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

/**
* @param string $message
Expand All @@ -23,23 +22,23 @@ public function __construct(string $message = "", int $code = 0, ?Exception $inn
}

/**
* Set raw response from API
* Set HTTP response status code from API
*
* @param ResponseInterface $response
* @param int $statusCode
* @return void
*/
public function setResponse(ResponseInterface $response): void
public function setResponseStatusCode(int $statusCode): void
{
$this->response = $response;
$this->responseStatusCode = $statusCode;
}

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

0 comments on commit 59dd728

Please sign in to comment.