I have a bit of code that sometimes throw errors for different reasons. And I would like to get more informations about it. The problem is either I have nothing at all and my app break or I use try catch and get a whole bunch of stuff from xdebug_message that I can't really show the user.
Let's say I need to do a collection of object AND make sure that some argument is filled (For this case we have nullable=false in the entity). If I miss one of those two points Here is what I get with the following code :
// We create the event $event = new Entity\Event; $event->setType( $this->input->post( 'type' ) ); $event->setDescription( $this->input->post( 'description' ) ); $event->setPlace( $place ); $event->setUser( $user ); // We can now persist this entity: try { $em->persist( $event ); $em->flush(); } catch( \Doctrine\DBAL\DBALException $e ) { // Error When Persisting the Entity !! // 500 Internal Server Error // A generic error message, given when no more specific message is suitable $this->response( array( 'error' => $e ), 500 ); } $message = array( "success" => TRUE ); // Everything is fine $this->response( $message, 200 ); // 200 being the HTTP response code In this case, it returns:
{"error":{"xdebug_message":"
What I would like to do is that from this error message, automatically execute some function or send an explicit message to the front side for any configuration possible. I can't really use xdebug here, it is not very helpful for this purpose.
How can I get more explicit details from PHP or Doctrine itself ?
I'm working with Doctrine2 and Codeigniter 2.1 or 2 dont know.
Thanks