Exemplo n.º 1
0
 /**
  *  Inner Exception handler
  *
  * @param Exception $ex
  */
 public function exceptionHandler($ex)
 {
     restore_exception_handler();
     $errcode = $ex->getMessage();
     $errmsg = sprintf('caught exception, errcode:%s, trace: %s', $errcode, $ex->__toString());
     if ($pos = strpos($errcode, ' ')) {
         $errcode = substr($errcode, 0, $pos);
     }
     $this->endStatus = $errcode;
     if ($this->isUserErr($errcode)) {
         Logger::trace($errmsg);
     } else {
         Logger::fatal($errmsg);
     }
 }
Exemplo n.º 2
0
 /**
  * process
  */
 protected function process()
 {
     $className = $this->opts['c'];
     $cls = new $className();
     if (!method_exists($cls, 'execute')) {
         Color::error('方法execute不存在');
         $this->endStatus = self::ENDSTATUS_INIT;
         $this->help(1);
     }
     $rMethod = new \ReflectionMethod($cls, 'execute');
     $params = $rMethod->getParameters();
     $_opts = array();
     foreach ($params as $param) {
         $name = $param->getName();
         if (isset($args[$name])) {
             $_opts[] = $args[$name];
         } else {
             $_opts[] = null;
         }
     }
     try {
         call_user_func_array(array($cls, 'execute'), $_opts);
     } catch (Exception $ex) {
         Logger::fatal($ex->getMessage());
         $this->endStatus = self::ENDSTATUS_ERROR;
         exit(2);
     }
 }