php - symfony 2.1 + try / catch block isn't working in a console command -


i using console command executed via cron. want catch every exception , writing in log catch not working @ all.

the part of code throwing error when calling "ejecutar" (this on purpose) error printed in console code after catch dont print in log

<?php namespace daci\contratosbundle\command;  use symfony\bundle\frameworkbundle\command\containerawarecommand; use symfony\component\console\event\consoleexceptionevent;  use symfony\component\console\input\inputargument; use symfony\component\console\input\inputinterface; use symfony\component\console\output\outputinterface;  //logger use psr\log\loggerinterface;  use symfony\component\form\abstracttype; use symfony\component\form\formbuilderinterface;  use symfony\component\httpfoundation\request; use symfony\component\httpfoundation\response;  use symfony\component\templating\engineinterface;  class seguimientosremainderemailcommand extends containerawarecommand {     //administrador     protected $emailadmin       = "....@.....sv";     protected $clasephp         = "seguimientosremainderemailcommand.php";     protected $nombreproceso    = "seguimientosremainderemail";     protected $comando          = "dacicontratosbundle:seguimientos_remainder_email";     protected $descripcion      = "recordatorio semanal para seguimiento de contratos";     protected $tiempoejecucion  = "lun | 8:00am";     protected $mensaje          = "";     protected $asunto           = "itiges - servicio de notificaciones - ";      protected $logger;     protected $text         = "";     protected function configure()     {         $this->setname($this->comando)              ->setdescription($this->descripcion)              ->addargument('my_argument', inputargument::optional, 'argument description');     }      protected function execute(inputinterface $input, outputinterface $output)     {           try{             //logger             $this->logger = $this->getcontainer()->get('logger');             $this->text = strtoupper('---- inicio seguimientos remainder email -----');             $this->logger->info($this->text);              $this->getcontainer()->enterscope('request');             $this->getcontainer()->set('request', new \symfony\component\httpfoundation\request(), 'request');              ejecutar(); //here fails               $this->mensaje = "<strong>Éxito</strong>" ."<br/>";             $this->mensaje = $this->mensaje . "<strong>clase php:</strong>              ".$this->clasephp."<br/>";             $this->mensaje = $this->mensaje . "<strong>comando ejecutado:</strong>      ".$this->comando."<br/>";             $this->mensaje = $this->mensaje . "<strong>descripción:</strong>            ".$this->descripcion."<br/>";             $this->mensaje = $this->mensaje . "<strong>ejecución programada:</strong>   ".$this->tiempoejecucion."<br/>";             $datetime = new \datetime();             $this->mensaje = $this->mensaje . "<strong>hora de ejecución:</strong>      ".$datetime->format('y\-m\-d\ h:i:s');              $this->enviarmailadmin($this->comando, $this->mensaje);           }catch (\exception $re) {             $this->logger->error($re->getmessage());         }     } 

this error i'm trying catch catch kind of error/exception

fatal error: call undefined function daci\contratosbundle\command\ejecutar() in c:\dropbox\apache xampp\evaluacion_daci\src\daci\contratosbundle\command\segu imientosremainderemailcommand.php on line 82 

any idea whats going on?

from basics of php: try{} catch(){} block can catch errors thrown exception.

you didn't paste here error log (please it), think it's fatal error, or kind of.

remember, errors not catchable. inside try-catch broke script.


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -