Skip to content

Commit 9a4e0c6

Browse files
committed
改进HttpEnd
1 parent ae2e9a9 commit 9a4e0c6

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

src/think/Http.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,17 +261,22 @@ protected function renderException($request, Throwable $e)
261261
return $this->app->make(Handle::class)->render($request, $e);
262262
}
263263

264-
/**
264+
/**
265265
* HttpEnd
266266
* @param Response $response
267267
* @return void
268268
*/
269269
public function end(Response $response): void
270270
{
271-
$this->app->event->trigger(HttpEnd::class, $response);
272-
273-
//执行中间件
274-
$this->app->middleware->end($response);
271+
try {
272+
// 触发HttpEnd事件
273+
$this->app->event->trigger(HttpEnd::class, $response);
274+
// 执行中间件
275+
$this->app->middleware->end($response);
276+
} catch (Throwable $e) {
277+
// 记录异常
278+
$this->app->log->error($e->getMessage());
279+
}
275280

276281
// 写入日志
277282
$this->app->log->save();

0 commit comments

Comments
 (0)