use custom exception instead of the generic one
This commit is contained in:
parent
a187ae011c
commit
0fdba8c054
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Data;
|
||||
|
||||
use App\Exceptions\ItemNotFoundException;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Str;
|
||||
@ -43,9 +44,10 @@ class ItemsCollection
|
||||
/**
|
||||
* @param string $id
|
||||
* @return array
|
||||
* @throws ItemNotFoundException
|
||||
*/
|
||||
public function getItemById(string $id)
|
||||
public function getItemById(string $id): array
|
||||
{
|
||||
return $this->data[$id];
|
||||
return $this->data[$id] ?? throw new ItemNotFoundException('Item not found');
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user