From 8cf1423fff799f732d83df22857071f608973a63 Mon Sep 17 00:00:00 2001 From: Artem Otliaguzov Date: Tue, 24 Sep 2024 13:20:50 +0200 Subject: [PATCH] fix error message --- app/Services/EntityService.php | 11 +++++------ app/Services/NotificationService.php | 3 +-- composer.json | 3 ++- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/Services/EntityService.php b/app/Services/EntityService.php index 3b60515..41a48bc 100644 --- a/app/Services/EntityService.php +++ b/app/Services/EntityService.php @@ -5,7 +5,6 @@ use App\Models\Entity; use App\Models\Federation; use Exception; -use http\Exception\InvalidArgumentException; use Illuminate\Support\Facades\Storage; class EntityService @@ -20,7 +19,7 @@ public function saveMetadataToFederationFolder($entity_id, $federation_id): void $federation = Federation::find($federation_id); if (! $federation) { - throw new Exception("Federation $federation_id not found"); + throw new \Exception("Federation $federation_id not found"); } $this->saveEntityMetadataToFolder($entity_id, $federation->xml_id); } @@ -36,7 +35,7 @@ public function saveEntityMetadataToFolder($entity_id, $folderName): void $entity = Entity::find($entity_id); if (! $entity) { - throw new Exception("Entity not found with id $entity_id"); + throw new \Exception("Entity not found with id $entity_id"); } $fileName = $entity->file; if (! Storage::disk($diskName)->exists($folderName)) { @@ -56,11 +55,11 @@ public function deleteEntityMetadataFromFolder($fileName, $folderName): void if (Storage::disk($diskName)->exists($pathToFile)) { try { Storage::disk($diskName)->delete($pathToFile); - } catch (Exception $e) { - throw new InvalidArgumentException("Unable to delete file $pathToFile"); + } catch (\Exception $e) { + throw new \InvalidArgumentException("Unable to delete file $pathToFile"); } } else { - throw new InvalidArgumentException("Unable to delete file $pathToFile"); + throw new \InvalidArgumentException("Unable to delete file $pathToFile"); } } diff --git a/app/Services/NotificationService.php b/app/Services/NotificationService.php index c3854e0..d4b2ae5 100644 --- a/app/Services/NotificationService.php +++ b/app/Services/NotificationService.php @@ -12,14 +12,13 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Notification; -use InvalidArgumentException; class NotificationService { public static function sendModelNotification(Model $model, $notification): void { if (! method_exists($model, 'operators')) { - throw new InvalidArgumentException('The given model does not have an operators relationship.'); + throw new \InvalidArgumentException('The given model does not have an operators relationship.'); } $operators = $model->operators; diff --git a/composer.json b/composer.json index 0e8ee2d..dcf6851 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,8 @@ "guzzlehttp/guzzle": "^7.2", "laravel/framework": "^10.0", "laravel/tinker": "^2.7", - "livewire/livewire": "^2.10" + "livewire/livewire": "^2.10", + "ext-http": "*" }, "require-dev": { "barryvdh/laravel-debugbar": "^3.6",