我尝试在找不到页面时添加一个exeption,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 :(得分:0)
由于命名空间是极致的,因此您看起来像是复制了一些演示教程代码而捆绑包不存在。
您需要创建扩展\ Exception的OWN异常类,并在yml中传递其名称空间。