Symfony在错误404时获取一个例外

时间:2017-02-27 10:43:45

标签: symfony

当我有错误404时,我需要得到一个例外,

所以在我的配置中我添加了:

exception:
    codes:
        'Symfony\Component\Routing\Exception\ResourceNotFoundException': 404
        'Doctrine\ORM\OptimisticLockException': HTTP_CONFLICT
    messages:
        'Safebrands\SurveillanceApiBundle\Exception\MyExceptionWithASafeMessage': true

在我的MyExceptionWithASafeMessage中我有:

class MyExceptionWithASafeMessage extends \Exception
{
    public function __construct()
    {
        return "test";
    }
}

但是当我收到错误404时,不会改变任何内容,我已经错误404

0 个答案:

没有答案