我目前正在我的项目中使用以下内容:
当我调用$em->flush()时,我正在执行以下操作
try {
$this->em->flush();
} catch (\PDOException $e) {
switch ($e->getCode() {
case /*Depending of the codes*/:
throw new \Exception(/*Message that hides the real error and just gives the code and a user-friendly message*/);
}
}但是,此操作仍然显示任何Server错误,从而向用户公开查询和内部结构。我应该做些什么来捕捉这些错误并将它们转换成更好的消息?事先谢谢你。
发布于 2014-03-03 13:03:32
它显示异常,因为您要抛出异常。不要抛出它们或编写异常侦听器,也不要在catch块之后处理它们。请参阅这些谷歌和来自塞福尼
https://stackoverflow.com/questions/22133891
复制相似问题