\ Exception不会捕获Symfony的异常

时间:2017-05-29 14:31:32

标签: php symfony try-catch

我有以下方法:

function fooAction(Request $request){
    $response = new Response();

    try{
        // Doing some stuff
        return $response;
    }

    catch(\Doctrine\DBAL\DBALException $e) {
        $response->setStatusCode(500);
        $response->setContent($e->getMessage());
    }

    catch(\Exception $e ){
        $response->setStatusCode(500);
        $response->setContent($e->getMessage());
    }

    return $response;
}

当我调用它时,我得到一个带有空消息的状态代码500。我究竟做错了什么?

0 个答案:

没有答案