feat : admin driver name
This commit is contained in:
@@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Exception\Handler;
|
||||
|
||||
use App\Lib\AdminReturn;
|
||||
use App\Lib\Log;
|
||||
use Hyperf\Contract\StdoutLoggerInterface;
|
||||
use Hyperf\ExceptionHandler\ExceptionHandler;
|
||||
@@ -21,7 +22,7 @@ use Throwable;
|
||||
|
||||
class AppExceptionHandler extends ExceptionHandler
|
||||
{
|
||||
public function __construct(protected StdoutLoggerInterface $logger,protected Log $log)
|
||||
public function __construct(protected StdoutLoggerInterface $logger,protected Log $log,protected AdminReturn $return)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -33,7 +34,11 @@ class AppExceptionHandler extends ExceptionHandler
|
||||
$this->log->error(sprintf('%s[%s] in %s', $throwable->getMessage(), $throwable->getLine(), $throwable->getFile()));
|
||||
$this->log->error($throwable->getTraceAsString());
|
||||
|
||||
return $response->withHeader('Server', 'Hyperf')->withStatus(500)->withBody(new SwooleStream('Internal Server Error.'));
|
||||
$result = $this->return->error('Internal Server Error.');
|
||||
return $response->withHeader("Content-Type", "application/json")
|
||||
->withStatus(200)
|
||||
->withBody(new SwooleStream(json_encode($result, JSON_UNESCAPED_UNICODE)));
|
||||
// return $response->withHeader('Server', 'Hyperf')->withStatus(500)->withBody(new SwooleStream('Internal Server Error.'));
|
||||
}
|
||||
|
||||
public function isValid(Throwable $throwable): bool
|
||||
|
||||
Reference in New Issue
Block a user