From 0edb50c2ad420d1a47aedd13143ecd9ebb32836f Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sun, 11 Jul 2021 16:37:29 +0200 Subject: [PATCH] app/Jobs/ImportProfession.php: Add concrete exception classes. --- app/Jobs/ImportProfession.php | 7 ++++--- app/ProfessionImport/InvalidCharacterException.php | 7 +++++++ app/ProfessionImport/InvalidProfessionException.php | 7 +++++++ 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 app/ProfessionImport/InvalidCharacterException.php create mode 100644 app/ProfessionImport/InvalidProfessionException.php diff --git a/app/Jobs/ImportProfession.php b/app/Jobs/ImportProfession.php index 3d57d06..f5501ed 100644 --- a/app/Jobs/ImportProfession.php +++ b/app/Jobs/ImportProfession.php @@ -9,7 +9,8 @@ use App\Models\Recipe; use App\Models\RecipeCategory; use App\Models\Item; use App\Models\Spell; -use App\ProfessionImport\Exception; +use App\ProfessionImport\InvalidCharacterException; +use App\ProfessionImport\InvalidProfessionException; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldBeUnique; @@ -44,14 +45,14 @@ class ImportProfession implements ShouldQueue // Validate character name first. if ($character->name !== $data->player) { $message = sprintf('Wrong character: %s expected %s', $data->player, $character->name); - throw new Exception($message); + throw new InvalidCharacterException($message); } // Validate profession $profession = Profession::slug($data->profession->name)->first(); if (!$profession) { $message = sprintf('Invalid profession: %s', $data->profession->name); - throw new Exception($message); + throw new InvalidProfessionException($message); } // Find/Create specialization diff --git a/app/ProfessionImport/InvalidCharacterException.php b/app/ProfessionImport/InvalidCharacterException.php new file mode 100644 index 0000000..f683ecf --- /dev/null +++ b/app/ProfessionImport/InvalidCharacterException.php @@ -0,0 +1,7 @@ +