更新
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\mcp\service;
|
||||
|
||||
/**
|
||||
* AI 助手模块内的可预期错误:携带给调用方看的中文提示、机器可读的 reason 和 HTTP 状态码。
|
||||
*/
|
||||
class McpException extends \RuntimeException
|
||||
{
|
||||
public string $reason;
|
||||
|
||||
public int $httpStatus;
|
||||
|
||||
public function __construct(string $message, string $reason, int $httpStatus = 200)
|
||||
{
|
||||
parent::__construct($message);
|
||||
$this->reason = $reason;
|
||||
$this->httpStatus = $httpStatus;
|
||||
}
|
||||
|
||||
public static function unauthorized(string $message = '授权已失效,请在行知重新绑定甄养堂账号', string $reason = 'invalid_token'): self
|
||||
{
|
||||
return new self($message, $reason, 401);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user