Commit 09bd415a authored by 谢宇轩's avatar 谢宇轩

refactor(Policy): 修改定义

parent a83f16ea
......@@ -221,7 +221,7 @@ class Application implements ClientInterface
if ($response->getStatusCode() != 304) {
try {
$rpcResult = $this->option->errorHandlingPolicy()->process($response);
$rpcResult = $this->option->handlingPolicy()->process($response);
} catch (GuiltyResultException $exception) {
// 没有通过预期判定,转化为 SDK Exception
$this->lastRequestContext['error_message'] = $exception->getMessage();
......
......@@ -12,6 +12,8 @@ class ApplicationException extends ConnectException implements SdkExceptionInter
use QueryPath;
/**
* 应用异常
*
* @param string $message
* @param SdkRequest|null $request
* @param array<string, mixed> $handlerContext
......
......@@ -11,6 +11,8 @@ class GuiltyResultException extends UnexpectedValueException
private $options;
/**
* 判断为 API 逻辑错误的异常,会转化为 SDK Exception
*
* @param string $message
* @param array<string, mixed> $options
* @param int $code
......
......@@ -14,6 +14,8 @@ class SdkException extends BadResponseException implements SdkExceptionInterface
use QueryPath;
/**
* SDK 中的逻辑异常
*
* @param string $message
* @param SdkRequest $request
* @param ResponseInterface $response
......@@ -42,4 +44,4 @@ class SdkException extends BadResponseException implements SdkExceptionInterface
{
return $this->getHandlerContext();
}
}
\ No newline at end of file
}
......@@ -15,6 +15,8 @@ class TimeOutExcetpion extends ApplicationException implements SdkExceptionInter
protected $message = "time out.";
/**
* 请求超时异常
*
* @param SdkRequest $request
* @param Throwable|null $previous
*/
......@@ -25,4 +27,4 @@ class TimeOutExcetpion extends ApplicationException implements SdkExceptionInter
{
parent::__construct($this->message, $request, [], $previous);
}
}
\ No newline at end of file
}
......@@ -11,6 +11,8 @@ class UnknowResultException extends UnexpectedValueException
public $result;
/**
* 无法解析API返回的异常,会转化为 Application Exception
*
* @param string $message
* @param string $result
* @param int $code
......
......@@ -36,7 +36,7 @@ abstract class Option
* 错误处理策略
* @return HandlingPolicyInterface
*/
public function errorHandlingPolicy(): HandlingPolicyInterface
public function handlingPolicy(): HandlingPolicyInterface
{
return new DefaultErrorHandlingPolicy();
}
......
......@@ -41,11 +41,11 @@ class {{ Name }}Option extends Option
}
/**
* 错误处理策略
* 结果处理策略
*
* @return HandlingPolicyInterface
*/
public function errorHandlingPolicy(): HandlingPolicyInterface
public function handlingPolicy(): HandlingPolicyInterface
{
return new DefaultErrorHandlingPolicy();
}
......
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