Commit 86b883c1 authored by 谢宇轩's avatar 谢宇轩

fix: 控制异常范围

parent 5d1dd142
......@@ -107,8 +107,6 @@ class Application implements ClientInterface
* @param RequestInterface $request
* @return ResponseInterface
* @throws ApplicationException
* @throws GuzzleException
*
*/
public function sendRequest(RequestInterface $request): ResponseInterface
{
......@@ -173,7 +171,7 @@ class Application implements ClientInterface
$this->logger->error("sdk etrror, bad client!");
}
if (!($request instanceof SdkRequest)) {
throw $exception;
throw new ApplicationException($exception->getMessage(), null, [], $exception);
}
throw new ApplicationException($exception->getMessage(), $request, [], $exception);
}
......
......@@ -13,18 +13,18 @@ class ApplicationException extends ConnectException implements SdkExceptionInter
/**
* @param string $message
* @param SdkRequest $request
* @param SdkRequest|null $request
* @param array<string, mixed> $handlerContext
* @param Throwable|null $previous
*/
public function __construct(
string $message,
SdkRequest $request,
array $handlerContext = [],
?\Throwable $previous = null,
string $message,
SdkRequest $request = null,
array $handlerContext = [],
?\Throwable $previous = null
) {
$this->endpoint = $request->getEndpoint();
$this->action = $request->getAction();
$this->endpoint = is_null($request) ? "" : $request->getEndpoint();
$this->action = is_null($request) ? "" : $request->getAction();
parent::__construct($message, $request, $previous, $handlerContext);
}
}
\ No newline at end of file
}
......@@ -6,7 +6,6 @@ declare(strict_types=1);
namespace Jiwei\{{ Package }}\Endpoint;
use Closure;
use GuzzleHttp\Exception\GuzzleException;
use Jiwei\EasyHttpSdk\Application;
use Jiwei\EasyHttpSdk\Exception\SdkException;
use Jiwei\EasyHttpSdk\Exception\ApplicationException;
......@@ -50,7 +49,6 @@ class {{ Endpoint }}
* @throws ApplicationException
* @throws SdkException
* @throws TimeOutExcetpion
* @throws GuzzleException
*/
public function {{ item.Action }}({{ item.Args }}?Closure $catch = null, ?Closure $then = null)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment