diff --git a/bootstrap/app.php b/bootstrap/app.php index 0ae9ceb..f1e24fc 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -4,11 +4,7 @@ declare(strict_types=1); use Illuminate\Foundation\Application; use Illuminate\Foundation\Configuration\Exceptions; -use Illuminate\Http\Request; use Illuminate\Support\Env; -use Presentation\Api\Exceptions\ApiExceptionDispatcher; -use Presentation\Web\Exceptions\WebExceptionRenderer; -use Sentry\State\HubInterface; return Application::configure(Env::get('APP_BASE_PATH', dirname(__DIR__))) ->withRouting( @@ -18,28 +14,5 @@ return Application::configure(Env::get('APP_BASE_PATH', dirname(__DIR__))) health: '/up', ) ->withMiddleware(require __DIR__ . '/middlewares.php') - ->withExceptions(function (Exceptions $exceptions): void { - $exceptions->reportable(function (\Throwable $e): void { - if (app()->bound(HubInterface::class)) { - resolve(HubInterface::class)->captureException($e); - } - }); - - $exceptions->render(function (\Throwable $e, Request $request) { - $apiDispatcher = resolve(ApiExceptionDispatcher::class); - if ($apiResponse = $apiDispatcher->render($e, $request)) { - return $apiResponse; - } - - $webRenderer = resolve(WebExceptionRenderer::class); - if ($webResponse = $webRenderer->render($e, $request)) { - return $webResponse; - } - - return null; - }); - - $exceptions->shouldRenderJsonWhen( - fn (Request $request) => $request->is('api/*'), - ); - })->create(); + ->withExceptions(require __DIR__ . '/exceptions.php') + ->create();