Skip to content

Commit 2a5d491

Browse files
authored
update
1 parent d88bcaa commit 2a5d491

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/RenderExceptionWithWhoops.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use think\exception\Handle;
88
use think\exception\HttpResponseException;
9+
use think\exception\HttpException;
910
use think\Response;
1011
use Throwable;
1112
use Whoops\Handler\PrettyPageHandler;
@@ -69,6 +70,13 @@ protected function handleAjaxException(Throwable $e)
6970
],
7071
];
7172

72-
return Response::create($data, 'json', $e->getCode());
73+
$response = Response::create($data, 'json');
74+
75+
if ($e instanceof HttpException) {
76+
$statusCode = $e->getStatusCode();
77+
$response->header($e->getHeaders());
78+
}
79+
80+
return $response->code($statusCode ?? 500);
7381
}
7482
}

0 commit comments

Comments
 (0)