diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 5d40fb8b87de..2049d9c59c84 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -15,15 +15,16 @@ use Exception; use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Auth\AuthenticationException; use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundException; +use Illuminate\Database\Eloquent\RelationNotFoundException; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Http\Exceptions\ThrottleRequestsException; use Illuminate\Support\Arr; +use Illuminate\Support\Facades\Schema; use Illuminate\Validation\ValidationException; +use Sentry\State\Scope; use Symfony\Component\Debug\Exception\FatalThrowableError; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; -use Illuminate\Database\Eloquent\RelationNotFoundException; -use Sentry\State\Scope; use function Sentry\configureScope; class Handler extends ExceptionHandler @@ -55,9 +56,12 @@ class Handler extends ExceptionHandler */ public function report(Exception $exception) { + if(!Schema::hasTable('accounts')) + return; + if (app()->bound('sentry') && $this->shouldReport($exception)) { app('sentry')->configureScope(function (Scope $scope): void { - if (auth()->guard('contact')->user() && auth()->guard('contact')->user()->company->account->report_errors) { + if (auth()->guard('contact') && auth()->guard('contact')->user() && auth()->guard('contact')->user()->company->account->report_errors) { $scope->setUser([ 'id' => auth()->guard('contact')->user()->company->account->key, 'email' => "anonymous@example.com", diff --git a/app/Http/Controllers/BaseController.php b/app/Http/Controllers/BaseController.php index fe6e3f777c6a..3444d6983efe 100644 --- a/app/Http/Controllers/BaseController.php +++ b/app/Http/Controllers/BaseController.php @@ -23,6 +23,7 @@ use App\Utils\Traits\AppSetup; use Illuminate\Http\Request; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Request as Input; +use Illuminate\Support\Facades\Schema; use League\Fractal\Manager; use League\Fractal\Pagination\IlluminatePaginatorAdapter; use League\Fractal\Resource\Collection; @@ -319,7 +320,7 @@ class BaseController extends Controller // return redirect()->secure(request()->path()); // } - if ((bool)$this->checkAppSetup() !== false && $account = Account::all()->first()) { + if ((bool)$this->checkAppSetup() !== false && Schema::hasTable('accounts') && $account = Account::all()->first()) { $data = []; if (Ninja::isSelfHost()) {