public function beforeException(\Phalcon\Events\Event $event, \Phalcon\Mvc\Dispatcher $dispatcher, \Phalcon\Exception $exception)
 {
     switch ($exception->getCode()) {
         case $dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
         case $dispatcher::EXCEPTION_ACTION_NOT_FOUND:
             $dispatcher->forward(array('controller' => 'error', 'action' => 'notFound'));
             return false;
         default:
             $dispatcher->forward(array('controller' => 'error', 'action' => 'uncaughtException'));
             return false;
     }
 }
 /**
  * This action is executed before execute any action in the application
  *
  * @param Event $event
  * @param MvcDispatcher $dispatcher
  * @param Exception $exception
  * @return boolean
  */
 public function beforeException(Event $event, MvcDispatcher $dispatcher, Exception $exception)
 {
     error_log($exception->getMessage() . PHP_EOL . $exception->getTraceAsString());
     if ($exception instanceof DispatcherException) {
         switch ($exception->getCode()) {
             case Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
             case Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
                 $dispatcher->forward(array('controller' => 'errors', 'action' => 'show404'));
                 return false;
         }
     }
     $dispatcher->forward(array('controller' => 'errors', 'action' => 'show500'));
     return false;
 }
Beispiel #3
0
 public function __construct($message = '', $code = 0, \Exception $previous = null, $level = self::WARNING, $automaticLog = null, $logName = null)
 {
     parent::__construct($message, $code, $previous);
     $this->level = $level;
     $this->logName = $logName ?: static::$defaultLogName;
     false !== $automaticLog && static::$automaticLog and ExceptionManager::getDefault()->addException($this);
 }
Beispiel #4
0
 /**
  * String representation of the exception
  *
  * @return string
  */
 public function __toString()
 {
     if (version_compare(PHP_VERSION, '5.3.0', '<')) {
         if (null !== ($e = $this->getPrevious())) {
             return $e->__toString() . "\n\nNext " . parent::__toString();
         }
     }
     return parent::__toString();
 }
 /**
  *
  * @param string             $message
  * @param int                $code
  * @param null|int|Exception $previous,  when $previous is int,will use as status code
  * @param null               $statusCode
  */
 public function __construct($message, $code = 10000, $previous = null, $statusCode = null)
 {
     //Allow the third paramater to be statuscode
     if (is_numeric($previous)) {
         $statusCode = $previous;
         $previous = null;
     }
     if ($statusCode && is_numeric($statusCode) && $statusCode > 99 && $statusCode < 600) {
         $this->statusCode = $statusCode;
     }
     parent::__construct($message, $code, $previous);
 }
 public function __construct($message, $code = 0, Exception $previous = null)
 {
     $messages = Utils::getMessagesFromStringOrArray($message);
     // make sure everything is assigned properly
     parent::__construct($messages, $code, $previous);
 }
 /**
  * Logs error messages.
  *
  * Events:
  * * breadcrumbs:beforeLogging
  * * breadcrumbs:afterLogging
  *
  * @param \Exception $e
  */
 protected function log(\Exception $e)
 {
     $eventsManager = $this->getEventsManager();
     if ($eventsManager) {
         $eventsManager->fire('breadcrumbs:beforeLogging', $this, [$e]);
     }
     if ($this->logger) {
         $this->logger->error($e->getMessage());
     } else {
         error_log($e->getMessage());
     }
     if ($eventsManager) {
         $eventsManager->fire('breadcrumbs:afterLogging', $this, [$e]);
     }
 }
Beispiel #8
0
 /**
  * Create exception.
  *
  * @param string     $message  Exception message.
  * @param array      $args     Message arguments (for placeholders, sprintf).
  * @param int        $code     Exception code.
  * @param \Exception $previous Previous exception.
  */
 public function __construct($message = "", $args = [], $code = 0, \Exception $previous = null)
 {
     parent::__construct(vsprintf($message, $args), $code, $previous);
 }