Skip to content

Commit

Permalink
add:add response property to RpcResponseException.php(issue 1278)
Browse files Browse the repository at this point in the history
  • Loading branch information
lzylyd committed Jun 5, 2020
1 parent eb15f45 commit c9454e1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/rpc-client/src/Concern/ServiceTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ protected function __proxyCall(string $interfaceClass, string $methodName, array
Error::log($errorMsg);

// Only to throw message and code
throw new RpcResponseException($message, $code);
$rpcResponseException = new RpcResponseException($message, $code);
// set response property
$rpcResponseException->setRpcResponse($response);
// throw exception
throw $rpcResponseException;
}

return $response->getResult();
Expand Down
23 changes: 22 additions & 1 deletion src/rpc-client/src/Exception/RpcResponseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Swoft\Rpc\Client\Exception;

use Exception;
use Swoft\Rpc\Response;

/**
* Class RpcResponseException
Expand All @@ -12,5 +13,25 @@
*/
class RpcResponseException extends Exception
{
/**
* response property ,it will be set when client get an error.
* @var $rpcResponse Response
*/
private $rpcResponse;

}
/**
* @return Response
*/
public function getRpcResponse():Response
{
return $this->rpcResponse;
}

/**
* @param Response $rpcResponse
*/
public function setRpcResponse(Response $rpcResponse): void
{
$this->rpcResponse = $rpcResponse;
}
}

0 comments on commit c9454e1

Please sign in to comment.