app/Jobs/ImportProfession.php: Add concrete exception classes.
This commit is contained in:
parent
88995dab35
commit
0edb50c2ad
3 changed files with 18 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
7
app/ProfessionImport/InvalidCharacterException.php
Normal file
7
app/ProfessionImport/InvalidCharacterException.php
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace App\ProfessionImport;
|
||||
|
||||
class InvalidCharacterException extends Exception
|
||||
{
|
||||
}
|
||||
7
app/ProfessionImport/InvalidProfessionException.php
Normal file
7
app/ProfessionImport/InvalidProfessionException.php
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace App\ProfessionImport;
|
||||
|
||||
class InvalidProfessionException extends Exception
|
||||
{
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue