Skip to content

Commit

Permalink
Merge pull request #18 from ucloud/feat/save-exception-resp
Browse files Browse the repository at this point in the history
[Feature] support save original response in exception
  • Loading branch information
wangrzneu committed Dec 14, 2023
2 parents 1e0936d + 2c5635f commit 1b3ea64
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/Core/Exception/UCloudException.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php


namespace UCloud\Core\Exception;

use Exception;
use Throwable;
use UCloud\Core\Response\Response;

class UCloudException extends Exception
{
Expand All @@ -30,6 +30,12 @@ class UCloudException extends Exception
*/
private $requestId;

/**
* Original Response
*
* @var Response|null
*/
private $response;
/**
* UCloudException constructor.
*
Expand All @@ -38,11 +44,13 @@ class UCloudException extends Exception
* @param int|int $retCode
* @param Throwable|null $previous
* @param string $requestId
* @param Response|null $response
*/
public function __construct($type, $message = "", $retCode = 0, $previous = null, $requestId = "")
public function __construct($type, $message = "", $retCode = 0, $previous = null, $requestId = "", $response = null)
{
$this->type = $type;
$this->requestId = $requestId;
$this->response = $response;
parent::__construct($message, $retCode, $previous);
}

Expand All @@ -65,4 +73,14 @@ public function getRequestId()
{
return $this->requestId;
}

/**
* Get response
*
* @return Response|null
*/
public function getResponse()
{
return $this->response;
}
}

0 comments on commit 1b3ea64

Please sign in to comment.