Esempio n. 1
0
 /**
  * Handle an error event. Called by error handler and exception handler.
  * @param string  $type    error type : 'error', 'warning', 'notice'
  * @param integer $code    error code
  * @param string  $message error message
  * @param string  $file    the file name where the error appear
  * @param integer $line    the line number where the error appear
  * @param array   $trace   the stack trace
  * @since 1.1
  */
 public function handleError($type, $code, $message, $file, $line, $trace)
 {
     $errorLog = new \Jelix\Logger\Message\Error($type, $code, $message, $file, $line, $trace);
     $errorLog->setFormat(App::config()->error_handling['messageLogFormat']);
     \Jelix\Logger\Log::log($errorLog, $type);
     // if non fatal error, it is finished, continue the execution of the action
     if ($type != 'error') {
         return;
     }
     $this->errorMessage = $errorLog;
     while (ob_get_level() && @ob_end_clean()) {
     }
     $resp = $this->request->getErrorResponse($this->response);
     $resp->outputErrors();
     \jSession::end();
     exit(1);
 }
Esempio n. 2
0
 /**
  * initialize the given request and some properties of the router
  *
  * It extracts information for the request to set the module name and the
  * action name. It doesn't verify if the corresponding controller does
  * exist or not.
  * It enables also the error handler of Jelix, if needed.
  * Does not call this method directly in entry points. Prefer to call
  * process() instead (that will call setRequest). 
  * setRequest is mostly used for tests or specific contexts.
  * @param  ClientRequest  $request the request object
  * @throw \jException if the module is unknown or the action name format is not valid
  * @see Router::process()
  */
 protected function setRequest($request)
 {
     $config = App::config();
     $this->request = $request;
     if ($config->enableErrorHandler) {
         set_error_handler(array($this, 'errorHandler'));
         set_exception_handler(array($this, 'exceptionHandler'));
         // let's log messages appeared during init
         foreach (\jBasicErrorHandler::$initErrorMessages as $msg) {
             \Jelix\Logger\Log::log($msg, $msg->getCategory());
         }
     }
     $this->request->init();
     list($this->moduleName, $this->actionName) = $request->getModuleAction();
     App::pushCurrentModule($this->moduleName);
     $this->action = $this->originalAction = new \jSelectorActFast($this->request->type, $this->moduleName, $this->actionName);
     if ($config->modules[$this->moduleName . '.access'] < 2) {
         throw new \jException('jelix~errors.module.untrusted', $this->moduleName);
     }
 }