diff --git a/system/Debug/Exceptions.php b/system/Debug/Exceptions.php index a65be7a2ad2f..e8249271733a 100644 --- a/system/Debug/Exceptions.php +++ b/system/Debug/Exceptions.php @@ -109,7 +109,9 @@ public function exceptionHandler(Throwable $exception) if (! is_cli()) { $this->response->setStatusCode($statusCode); - header(sprintf('HTTP/%s %s %s', $this->request->getProtocolVersion(), $this->response->getStatusCode(), $this->response->getReasonPhrase()), true, $statusCode); + if (! headers_sent()) { + header(sprintf('HTTP/%s %s %s', $this->request->getProtocolVersion(), $this->response->getStatusCode(), $this->response->getReasonPhrase()), true, $statusCode); + } if (strpos($this->request->getHeaderLine('accept'), 'text/html') === false) { $this->respond(ENVIRONMENT === 'development' ? $this->collectVars($exception, $statusCode) : '', $statusCode)->send();