$throwable->getCode(), 'message' => $throwable->getMessage(), 'data' => [] ], JSON_UNESCAPED_UNICODE); // 阻止异常冒泡 $this->stopPropagation(); return $response->withAddedHeader('content-type', 'application/json; charset=utf-8')->withStatus(401)->withBody(new SwooleStream($data)); } return $response; } /** * 判断该异常处理器是否要对该异常进行处理 */ public function isValid(Throwable $throwable): bool { return true; } }