symfony - Symfony 2 - 在生产中不返回 POST Json 自定义消息异常
问题描述
我正在使用 Symfony 2.8
我有一个 POST 方法根。返回格式为json。
app_patient_create:
path: /
methods: [POST]
defaults:
_controller: App:Patient:create
_format: json
_angular_safe: true
在这个根目录的监听器中,我有一个例外。
throw new Exception\MaxPointsException();
这是自定义异常:
namespace App\Training\Exception;
class MaxPointsException extends \LogicException
{
public function __construct()
{
parent::__construct('Vous avez atteint le nombre maximal de patients inclus dans votre offre découverte. Pour continuer à profiter du site, veuillez vous abonner');
}
}
在开发环境中,消息是 return :
但不在产品环境中:
你知道为什么吗?
解决方案
我使用 HTTP 409 响应来识别我的异常。
推荐阅读
- git - Git rebase:使用合并而不是 rebase 解决冲突
- c# - 有没有办法在运行时根据用户选择的特定表动态创建模型
- python - get_object_or_404 can't find object with primary key
- javascript - Angular中的窗口聚焦过程
- excel - 当 Excel 中的数据源更新时,电源查询运行后硬编码的值错位
- html - 隐藏在 Angular 中无法使用 Array
- r - 在R数据帧中减去对角线?
- smartgit - 如何让 SmartGit 一次只显示一个存储库?
- c++ - 如何在 C++ 中返回没有模板的泛型类型?
- javascript - 利用 localStorage 的简单无线电形式在移动设备上不起作用