Hi,
I'm wondering how to manage Exception in
AbstractRestfulController
I set up the
http://hounddog.github.com/blog/getting-started-with-rest-and-zend-framework-2/
project and I've tried with
public function create($data)
{
try{
$artist = $this->getRequest()->getPost('artist', null);
$title = $this->getRequest()->getPost('title', null);
$album = new Album();
$album->exchangeArray(array('artist'=>$artist,'title'=>$title));
$id = $this->getAlbumTable()->saveAlbum($album);
return $this->get($id);
}
catch (Exception $e) {
return new JsonModel(array(
'meta' =>array(
'code'=>500,
'error-num'=>$e->getCode(),
'error-msg'=>$e->getMessage(),
)
));
}
}
and also with
public function saveAlbum(Album $album)
{
try{
$this->tableGateway->insert($data);
$id = $this->tableGateway->getLastInsertValue();
return $id;
}
catch (Exception $e) {
return new JsonModel(array(
'meta' =>array(
'code'=>500,
'error-num'=>$e->getCode(),
'error-msg'=>$e->getMessage(),
)
));
}
}
but I keeping on having the all Exception stack
I mean with the whole layout.
My goal is get a json like
{
"meta": {
"error_type": "error type",
"code": 400,
"error_message": "error msg"
}
}
What's the right way ?
--
View this message in context:
http://zend-framework-community.634137.n4.nabble.com/zend-2-AbstractRestfulController-how-to-manage-Exception-tp4659479.html
Sent from the Zend Framework mailing list archive at Nabble.com.
--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]