2
我嘗試在try的catch部分引入錯誤500頭。我通過Ajax在symfony控制器方法中調用我的API方法。我的問題是,我無法顯示,因爲這個symfony的警告頁面如何跳過symfony2警告消息
這裏的API端代碼的錯誤消息:
try{
//Some code
}catch (Exception $e){
header('HTTP/1.1 500 Internal Server Error');
die($e->getMessage()); // I get this message in the error part of the ajax call
}
控制器的方法:
public function createModelAction(){
$mail = "test";
$pass = "test";
$oauth = new OAuth($mail, $pass);
$baseUrl = $this->container->getParameter('url_api');
// Récupération des rapports d'avis du réseau demandé
$link = "{$baseUrl}model/" . $mail . "/" . $pass . "/test";
$oauth->fetch($link, $_REQUEST, OAUTH_HTTP_METHOD_POST);
$response = json_decode($oauth->getLastResponse(), true);
if ($response['error']) {
return new JsonResponse($response['error']);
} else {
return new JsonResponse($response['model']);
}
}
所以任何替代方案都可以跳過這個問題
感謝
你可以顯示你的控制器嗎? –