2017-02-27 67 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。