28 lines
673 B
PHP
28 lines
673 B
PHP
<?php
|
|
|
|
namespace app\exception;
|
|
|
|
use Webman\Http\Request;
|
|
use Webman\Http\Response;
|
|
use function json_encode;
|
|
|
|
class AjaxException extends \RuntimeException
|
|
{
|
|
public function render(Request $request): Response
|
|
{
|
|
return new Response(
|
|
200,
|
|
['Content-Type' => 'application/json'],
|
|
json_encode(
|
|
[
|
|
'code' => $this->getCode() ?: 500,
|
|
'msg' => $this->getMessage(),
|
|
'data' => [],
|
|
'time' => time()
|
|
],
|
|
JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES
|
|
)
|
|
);
|
|
|
|
}
|
|
} |