viewFactory = $viewFactory;
$this->listener = $listener;
$this->htmlErrorRenderer = $htmlErrorRenderer;
$this->bladeMapper = $bladeMapper;
$this->basePath = $basePath;
}
/**
* Render the given exception as an HTML string.
*
* @param \Illuminate\Http\Request $request
* @param \Throwable $throwable
* @return string
*/
public function render(Request $request, Throwable $throwable)
{
$flattenException = $this->bladeMapper->map(
$this->htmlErrorRenderer->render($throwable),
);
return $this->viewFactory->make('laravel-exceptions-renderer::show', [
'exception' => new Exception($flattenException, $request, $this->listener, $this->basePath),
])->render();
}
/**
* Get the renderer's CSS content.
*
* @return string
*/
public static function css()
{
return (new Collection([
['styles.css', []],
['light-mode.css', ['data-theme' => 'light']],
['dark-mode.css', ['data-theme' => 'dark']],
]))->map(function ($fileAndAttributes) {
[$filename, $attributes] = $fileAndAttributes;
return '';
})->implode('');
}
/**
* Get the renderer's JavaScript content.
*
* @return string
*/
public static function js()
{
$viteJsAutoRefresh = '';
$vite = app(\Illuminate\Foundation\Vite::class);
if (is_file($vite->hotFile())) {
$viteJsAutoRefresh = $vite->__invoke([]);
}
return ''.$viteJsAutoRefresh;
}
}