console = console(); $this->logger = container()->get(LoggerFactory::class)->get('mineAdmin'); } public function handle(Throwable $throwable, ResponseInterface $response): ResponseInterface { $this->console->error(sprintf('%s[%s] in %s', $throwable->getMessage(), $throwable->getLine(), $throwable->getFile())); $this->console->error($throwable->getTraceAsString()); $this->logger->error(sprintf('%s[%s] in %s', $throwable->getMessage(), $throwable->getLine(), $throwable->getFile())); $format = [ 'success' => false, 'code' => 500, 'message' => $throwable->getMessage() ]; return $response->withHeader('Server', 'MineAdmin') ->withAddedHeader('content-type', 'application/json; charset=utf-8') ->withStatus(500)->withBody(new SwooleStream(Json::encode($format))); } public function isValid(Throwable $throwable): bool { return true; } }