Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexVanderbist committed May 19, 2021
1 parent e8be63b commit a17e83a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"ext-mbstring": "*",
"facade/flare-client-php": "^1.6",
"facade/ignition-contracts": "^1.0.2",
"filp/whoops": "^2.4",
"illuminate/support": "^7.0|^8.0",
"monolog/monolog": "^2.0",
"symfony/console": "^5.0",
Expand Down
25 changes: 25 additions & 0 deletions src/ErrorPage/IgnitionExceptionHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Facade\Ignition\ErrorPage;

use Illuminate\Contracts\Foundation\ExceptionRenderer;

class IgnitionExceptionHandler implements ExceptionRenderer
{
/** @var \Facade\Ignition\ErrorPage\ErrorPageHandler */
protected $errorPageHandler;

public function __construct(ErrorPageHandler $errorPageHandler)
{
$this->errorPageHandler = $errorPageHandler;
}

public function render($throwable)
{
ob_start();

$this->errorPageHandler->handle($throwable);

return ob_get_clean();
}
}
17 changes: 12 additions & 5 deletions src/IgnitionServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
use Livewire\CompilerEngineForIgnition;
use Monolog\Logger;
use Throwable;
use Whoops\Handler\HandlerInterface;

class IgnitionServiceProvider extends ServiceProvider
{
Expand Down Expand Up @@ -113,8 +112,8 @@ public function register()

$this
->registerSolutionProviderRepository()
->registerRenderer()
->registerExceptionRenderer()
->registerWhoopsHandler()
->registerIgnitionConfig()
->registerFlare()
->registerDumpCollector();
Expand Down Expand Up @@ -196,7 +195,7 @@ protected function registerSolutionProviderRepository()
return $this;
}

protected function registerExceptionRenderer()
protected function registerRenderer()
{
$this->app->bind(Renderer::class, function () {
return new Renderer(__DIR__.'/../resources/views/');
Expand All @@ -205,11 +204,19 @@ protected function registerExceptionRenderer()
return $this;
}

protected function registerWhoopsHandler()
protected function registerExceptionRenderer()
{
$this->app->bind(HandlerInterface::class, function (Application $app) {
if (class_exists(\Whoops\Handler\HandlerInterface::class)) {
$this->app->bind(\Whoops\Handler\HandlerInterface::class, function (Application $app) {
return $app->make(IgnitionWhoopsHandler::class);
});
}

if (class_exists(\Illuminate\Contracts\Foundation\ExceptionRenderer::class)) {
$this->app->bind(\Illuminate\Contracts\Foundation\ExceptionRenderer::class, function (Application $app) {
return $app->make(IgnitionWhoopsHandler::class);
});
}

return $this;
}
Expand Down

0 comments on commit a17e83a

Please sign in to comment.