use custom exception instead of the generic one

This commit is contained in:
Rev 2021-10-10 13:09:11 +09:00
parent a187ae011c
commit 0fdba8c054

View File

@ -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');
}
}