symfony2 and throwing exception error

前端 未结 3 431
太阳男子
太阳男子 2021-01-01 12:13

I am trying to throw exceptions and I am doing the following:

use Symfony\\Component\\HttpKernel\\Exception\\HttpNotFoundException;
use Symfony\\Component\\S         


        
3条回答
  •  旧时难觅i
    2021-01-01 12:29

    Try:

    use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
    

    and

    throw new NotFoundHttpException("Page not found");
    

    I think you got it a bit backwards :-)

提交回复
热议问题