dtup3446 2013-05-06 09:20
浏览 73
已采纳

为什么Symfony 2不输出HTTP异常的错误文本?

I'm making an API of sorts. The user must include a token in the request, and if it's not valid, I simply throw a 403 ACCESS DENIED exception. The issue is that after the token has been accepted, there are lots of other rules for what input is allowed. If the user inputs invalid query parameters, I want to return status 400 (bad request) with a small message explaining why the request was bad. In the dev environment I see the printout of the exception, of course, but in the production environment, only the status code is displayed.

Is there any way of getting Symfony to also print the text passed to the exception constructor?

Note: I am aware that this could be a security risk, so I intend to only return 403 ACCESS DENIED errors until the user has proven their identity.

  • 写回答

2条回答 默认 最新

  • douzong7283 2013-05-06 09:30
    关注

    Thrown Exceptions are handled within the core TwigBundle. Symfony allows you to customize the error templates.

    Take a deeper look at this section of the documentation.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?