From ef45c25f175df0266ad59bae4b2466f914769d43 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 9 Jul 2024 17:01:57 +0300 Subject: [PATCH 1/3] Prevent 500 error without logs --- app/Exceptions/Handler.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 93c44c99afb7..c580e7b3feae 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -94,11 +94,6 @@ class Handler extends ExceptionHandler */ public function report(Throwable $exception) { - if (! Schema::hasTable('accounts')) { - info('account table not found'); - return; - } - if (Ninja::isHosted()) { // if($exception instanceof ThrottleRequestsException && class_exists(\Modules\Admin\Events\ThrottledExceptionRaised::class)) { From b35eddd54bf47d533105c5bc4b4713780d023015 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 9 Jul 2024 19:39:37 +0300 Subject: [PATCH 2/3] Help guide setting up the app --- app/Exceptions/Handler.php | 5 +++++ resources/views/portal/ninja2020/layout/error.blade.php | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index c580e7b3feae..3ab3c69eb143 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -18,6 +18,7 @@ use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Auth\AuthenticationException; use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundException; use Illuminate\Database\Eloquent\RelationNotFoundException; +use Illuminate\Encryption\MissingAppKeyException; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Http\Exceptions\ThrottleRequestsException; use Illuminate\Http\Request; @@ -149,6 +150,10 @@ class Handler extends ExceptionHandler } parent::report($exception); + + if (Ninja::isSelfHost() && $exception instanceof MissingAppKeyException) { + \Log::error('To setup the app run "cp .env.example .env" followed by "php artisan key:generate"'); + } } private function validException($exception) diff --git a/resources/views/portal/ninja2020/layout/error.blade.php b/resources/views/portal/ninja2020/layout/error.blade.php index b04dacd5bb5b..b42e706d78f0 100644 --- a/resources/views/portal/ninja2020/layout/error.blade.php +++ b/resources/views/portal/ninja2020/layout/error.blade.php @@ -10,11 +10,17 @@
-
+
@yield('code') — @yield('message') + @if (\App\Utils\Ninja::isSelfHost()) + + Check storage/logs for more details + + @endif + {{ ctrans('texts.back_to', ['url' => parse_url(request()->getHttpHost())['host'] ?? request()->getHttpHost()]) }} From 8ca30a590fa3c4a5a5b2b73409aec22fa59e0a17 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 9 Jul 2024 23:23:10 +0300 Subject: [PATCH 3/3] Change from \Log::error() to info() --- app/Exceptions/Handler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 3ab3c69eb143..a6f286c78d3b 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -152,7 +152,7 @@ class Handler extends ExceptionHandler parent::report($exception); if (Ninja::isSelfHost() && $exception instanceof MissingAppKeyException) { - \Log::error('To setup the app run "cp .env.example .env" followed by "php artisan key:generate"'); + info('To setup the app run "cp .env.example .env" followed by "php artisan key:generate"'); } }