add
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
namespace app\exception;
|
||||
|
||||
use RuntimeException;
|
||||
use support\Response;
|
||||
|
||||
class HttpResponseException extends RuntimeException
|
||||
{
|
||||
protected $response;
|
||||
|
||||
// 接收 Response 实例作为参数
|
||||
public function __construct(Response $response)
|
||||
{
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
// 获取响应对象
|
||||
public function getResponse()
|
||||
{
|
||||
return $this->response;
|
||||
}
|
||||
}
|
||||
14
app/exception/MyBusinessException.php
Normal file
14
app/exception/MyBusinessException.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace app\exception;
|
||||
|
||||
use support\exception\BusinessException;
|
||||
use Webman\Http\Request;
|
||||
use Webman\Http\Response;
|
||||
|
||||
class MyBusinessException extends BusinessException
|
||||
{
|
||||
public function render(Request $request): ?Response
|
||||
{
|
||||
return new Response(200, ['Content-Type' => 'application/json'], $this->getMessage());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user