Skip to content

Commit

Permalink
save original response in EXC_TYPE_RET_CODE type exception
Browse files Browse the repository at this point in the history
  • Loading branch information
wangrzneu committed Dec 14, 2023
1 parent 9677ada commit b11a93f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
22 changes: 21 additions & 1 deletion src/Core/Exception/UCloudException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

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


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

/**
* Original Response
*
* @var Response
*/
private $response;
/**
* UCloudException constructor.
*
Expand All @@ -38,11 +46,13 @@ class UCloudException extends Exception
* @param int|int $retCode
* @param Throwable|null $previous
* @param string $requestId
* @param Response $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 +75,14 @@ public function getRequestId()
{
return $this->requestId;
}

/**
* Get response
*
* @return Response
*/
public function getResponse()
{
return $this->response;
}
}
3 changes: 2 additions & 1 deletion src/Core/Transport/Transport.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ public function invoke(Request $req)
$resp->getMessage(),
$resp->getRetCode(),
null,
$requestId
$requestId,
$resp
);
}
return $resp;
Expand Down

0 comments on commit b11a93f

Please sign in to comment.