I am working with Symfony 2, and I am trying to make a small problem solver bundle.
I have the entity Problem
that contains a retry
field, containing information on which command to execute to retry what failed before.
So here is the code of my controller:
public function retryAction($id)
{
$em = $this->getDoctrine()->getManager();
$problem = $em->getRepository('RBLogsBundle:Problem')->find($id);
$kernel = $this->get('kernel');
$application = new Application($kernel);
$application->setAutoExit(false);
$input = new ArrayInput($problem->getRetry());
$output = new BufferedOutput();
$application->run($input,$output);
$content = $output->fetch();
return new Response($content);
}
When my command fails, it normally throws an exception. However here, the Exception thrown during the command just seems to stop the command, but the execution of my controller continues.
How could I know in my controller if the command ended good or bad?
I'm sorry, I found the solution in the Application
class that contains a setCatchExceptions()
method. The solution is the one below:
$application = new Application($kernel);
$application->setCatchExceptions(false);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With