Come catturare l'eccezione nel controller e mostrare il messaggio flash in Symfony 2?Come catturare l'eccezione in symfony 2?
try{
$em = $this->getDoctrine()->getManager();
$em->persist($entity);
$em->flush();
return $this->redirect($this->generateUrl('target page'));
} catch(\Exception $e){
// What to do in this part???
}
return $this->render('MyTestBundle:Article:new.html.twig', array(
'entity' => $entity,
'form' => $form->createView(),
));
Cosa devo fare nel blocco catch
?
http://stackoverflow.com/questions/5689415/symfony2-controller-wont-catch-exception – Asif
toString ($ e) non funziona. Mostra FatalErrorException: Errore: chiamata alla funzione non definita toString() – Swass
'echo (stringa) $ e;' o meglio, inviare una e-mail su un sito produttivo: 'mail ('[email protected] ',' Eccezione in script ... ', var_export ($ e, true)); ' – DanFromGermany