Throwing Exceptions in CakePHP4
![](/img/article-type-images/20211004-025529-cakephp4-type.png)
Throwing Exceptions in CakePHP4
In your controller:
use Cake\Http\Exception\NotFoundException;
In your method:
if(.....) { throw new NotFoundException(__('Article not found')); }
Other Resources:
For a complete list of excemptions in CakePHP4, see the documentation:
https://book.cakephp.org/4/en/development/errors.html#built-in-exceptions-for-cakephp