willdurand/Propilex — comment on commit e4ec228ff74ef18cfba043099cd48bbc8ab138d8
File: src/Propilex/Provider/RestControllerProvider.php line 35
By stof:

Throw a ``Symfony\Component\HttpKernel\Exception\NotFoundHttpException`` for this. In fact, it can work for any status code using ``Symfony\Component\HttpKernel\Exception\HttpException`` (the previous one being a shortcut for 404 ones). Btw, this is the one used by ``abort``.

In Symfony2, the convention is to always use the exception for error responses (4xx and 5xx) so that they are handled consistently by the exception controller. And the most basic exception handler also takes care of these special exception classes.