upgrade to laravel 7 and set branch to v2
This commit is contained in:
@@ -40,6 +40,8 @@ class HtmlErrorRenderer implements ErrorRendererInterface
|
||||
private $outputBuffer;
|
||||
private $logger;
|
||||
|
||||
private static $template = 'views/error.html.php';
|
||||
|
||||
/**
|
||||
* @param bool|callable $debug The debugging mode as a boolean or a callable that should return it
|
||||
* @param string|FileLinkFormatter|null $fileLinkFormat
|
||||
@@ -48,11 +50,11 @@ class HtmlErrorRenderer implements ErrorRendererInterface
|
||||
public function __construct($debug = false, string $charset = null, $fileLinkFormat = null, string $projectDir = null, $outputBuffer = '', LoggerInterface $logger = null)
|
||||
{
|
||||
if (!\is_bool($debug) && !\is_callable($debug)) {
|
||||
throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a boolean or a callable, "%s" given.', __METHOD__, \is_object($debug) ? \get_class($debug) : \gettype($debug)));
|
||||
throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a boolean or a callable, "%s" given.', __METHOD__, get_debug_type($debug)));
|
||||
}
|
||||
|
||||
if (!\is_string($outputBuffer) && !\is_callable($outputBuffer)) {
|
||||
throw new \TypeError(sprintf('Argument 5 passed to "%s()" must be a string or a callable, "%s" given.', __METHOD__, \is_object($outputBuffer) ? \get_class($outputBuffer) : \gettype($outputBuffer)));
|
||||
throw new \TypeError(sprintf('Argument 5 passed to "%s()" must be a string or a callable, "%s" given.', __METHOD__, get_debug_type($outputBuffer)));
|
||||
}
|
||||
|
||||
$this->debug = $debug;
|
||||
@@ -68,9 +70,13 @@ class HtmlErrorRenderer implements ErrorRendererInterface
|
||||
*/
|
||||
public function render(\Throwable $exception): FlattenException
|
||||
{
|
||||
$exception = FlattenException::createFromThrowable($exception, null, [
|
||||
'Content-Type' => 'text/html; charset='.$this->charset,
|
||||
]);
|
||||
$headers = ['Content-Type' => 'text/html; charset='.$this->charset];
|
||||
if (\is_bool($this->debug) ? $this->debug : ($this->debug)($exception)) {
|
||||
$headers['X-Debug-Exception'] = rawurlencode($exception->getMessage());
|
||||
$headers['X-Debug-Exception-File'] = rawurlencode($exception->getFile()).':'.$exception->getLine();
|
||||
}
|
||||
|
||||
$exception = FlattenException::createFromThrowable($exception, null, $headers);
|
||||
|
||||
return $exception->setAsString($this->renderException($exception));
|
||||
}
|
||||
@@ -132,7 +138,7 @@ class HtmlErrorRenderer implements ErrorRendererInterface
|
||||
$statusCode = $this->escape($exception->getStatusCode());
|
||||
|
||||
if (!$debug) {
|
||||
return $this->include('views/error.html.php', [
|
||||
return $this->include(self::$template, [
|
||||
'statusText' => $statusText,
|
||||
'statusCode' => $statusCode,
|
||||
]);
|
||||
@@ -345,8 +351,19 @@ class HtmlErrorRenderer implements ErrorRendererInterface
|
||||
{
|
||||
extract($context, \EXTR_SKIP);
|
||||
ob_start();
|
||||
include __DIR__.'/../Resources/'.$name;
|
||||
|
||||
include file_exists($name) ? $name : __DIR__.'/../Resources/'.$name;
|
||||
|
||||
return trim(ob_get_clean());
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows overriding the default non-debug template.
|
||||
*
|
||||
* @param string $template path to the custom template file to render
|
||||
*/
|
||||
public static function setTemplate(string $template): void
|
||||
{
|
||||
self::$template = $template;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user