From f46117c8e6ce2e783923035851b4e3d082eeec25 Mon Sep 17 00:00:00 2001 From: Ahmed Mardi Date: Thu, 4 May 2023 03:23:24 +0300 Subject: [PATCH] Wip --- .github/README.md | 9 +++++++++ src/Sleuren.php | 6 ++++-- tests/SleurenTest.php | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/README.md b/.github/README.md index bdc74ae..a0e3563 100644 --- a/.github/README.md +++ b/.github/README.md @@ -71,3 +71,12 @@ SLEUREN_KEY= > **SLEUREN_KEY:** is your Project API key which you've received when creating a project. Get the variables from your [Sleuren dashboard](https://sleuren.com/dashboard). + +Run this in your terminal to test if everything is working: +```bash +php artisan sleuren:test +``` + +## Documentation + +For more information, see the [documentation](https://help.sleuren.com). diff --git a/src/Sleuren.php b/src/Sleuren.php index 16b8001..b5abd3a 100644 --- a/src/Sleuren.php +++ b/src/Sleuren.php @@ -154,8 +154,10 @@ public function getExceptionData(Throwable $exception) $data['method'] = Request::method(); $data['route'] = Request::path(); $data['fullUrl'] = Request::fullUrl(); - $data['controller'] = Request::route()->getAction()['controller'] ?? '-'; - $data['middleware'] = implode(',', Request::route()->gatherMiddleware()) ?? '-'; + if (Request::route()) { + $data['controller'] = Request::route()->getAction()['controller'] ?? '-'; + $data['middleware'] = implode(',', Request::route()->gatherMiddleware()) ?? '-'; + } $data['exception'] = $exception->getMessage() ?? '-'; $data['line'] = $exception->getLine(); $data['file'] = $exception->getFile(); diff --git a/tests/SleurenTest.php b/tests/SleurenTest.php index 81df94f..c5fc165 100644 --- a/tests/SleurenTest.php +++ b/tests/SleurenTest.php @@ -141,7 +141,7 @@ public function it_can_get_formatted_exception_data() $this->assertSame('http://localhost', $data['fullUrl']); $this->assertSame('it_can_get_formatted_exception_data', $data['exception']); - $this->assertCount(13, $data); + $this->assertCount(18, $data); } /** @test */