2017-02-27 101 views
0

我尝试添加exeption时没有发现IA页,404Symfony的FOSRestBundle异常错误404

所以我加这是ocnfig fos_rest:

# exception: 
#  codes: 
#   'Symfony\Component\Routing\Exception\ResourceNotFoundException': 404 
#   'Doctrine\ORM\OptimisticLockException': HTTP_CONFLICT 
#  messages: 
#   'Acme\HelloBundle\Exception\MyExceptionWithASafeMessage': true 

但我有此错误:

FOSRestBundle exception mapper: Could not load class 'Acme\HelloBundle\Exception\MyExceptionWithASafeMessage' or the class does not extend from '\Exception'. Most probably this is a configuration problem. 
+0

'Acme \ HelloBundle \ Exception \ MyExceptionWithASafeMessage''是否延伸'\ Exception'? – Mawcel

+0

像这样'Acme \ HelloBundle \ Exception \ MyExceptionWithASafeMessage'extend \ Exeption:true? 有了这个我有错误:不包含有效的YAML – Ygg69

+0

显示'Acme \ HelloBundle \ Exception \ MyExceptionWithASafeMessage'类的代码 – Mawcel

回答

0

由于命名空间是极致,它看起来像你复制了一些演示教程代码,并且该包不存在。

您需要创建您的OWN异常类,扩展\ Exception并将其名称空间传递给yml。