/** * 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) { global $gJConfig; $errorLog = new jLogErrorMessage($type, $code, $message, $file, $line, $trace); if ($this->request) { // we have config, so we can process "normally" $errorLog->setFormat($gJConfig->error_handling['messageLogFormat']); jLog::log($errorLog, $type); $this->allErrorMessages[] = $errorLog; // if non fatal error, it is finished if ($type != 'error') { return; } $this->errorMessage = $errorLog; while (ob_get_level()) { ob_end_clean(); } if ($this->response) { $resp = $this->response; } else { $resp = $this->response = new jResponseCmdline(); } $resp->outputErrors(); jSession::end(); } elseif ($type != 'error') { $this->allErrorMessages[] = $errorLog; $this->initErrorMessages[] = $errorLog; return; } else { // fatal error appeared during init, let's display a single message while (ob_get_level()) { ob_end_clean(); } // log into file @error_log($errorLog->getFormatedMessage(), 3, jApp::logPath('errors.log')); // output text response echo 'Error during initialization: ' . $message . ' (' . $file . ' ' . $line . ")\n"; } exit(1); }
public function handleError($type, $code, $message, $file, $line, $trace) { $errorLog = new jLogErrorMessage($type, $code, $message, $file, $line, $trace); $errorLog->setFormat(jApp::config()->error_handling['messageLogFormat']); jLog::log($errorLog, $type); $this->allErrorMessages[] = $errorLog; if ($type != 'error') { return; } $this->errorMessage = $errorLog; while (ob_get_level() && @ob_end_clean()) { } if ($this->response) { $resp = $this->response; } else { require_once JELIX_LIB_CORE_PATH . 'response/jResponseCmdline.class.php'; $resp = $this->response = new jResponseCmdline(); } $resp->outputErrors(); jSession::end(); exit(1); }
/** * 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) { global $gJConfig; $errorLog = new jLogErrorMessage($type, $code, $message, $file, $line, $trace); if ($this->request) { // we have config, so we can process "normally" $errorLog->setFormat($gJConfig->error_handling['messageLogFormat']); jLog::log($errorLog, $type); // if non fatal error, it is finished if ($type != 'error') { return; } $this->errorMessage = $errorLog; while (ob_get_level()) { ob_end_clean(); } $resp = $this->request->getErrorResponse($this->response); $resp->outputErrors(); jSession::end(); } elseif ($type != 'error') { $this->initErrorMessages[] = $errorLog; return; } else { // fatal error appeared during init, let's display an HTML page // since we don't know the request, we cannot return a response // corresponding to the expected protocol while (ob_get_level()) { ob_end_clean(); } // log into file @error_log($errorLog->getFormatedMessage(), 3, jApp::logPath('errors.log')); // if accept text/html if (isset($_SERVER['HTTP_ACCEPT']) && strstr($_SERVER['HTTP_ACCEPT'], 'text/html')) { if (file_exists(jApp::appPath('responses/error.en_US.php'))) { $file = jApp::appPath('responses/error.en_US.php'); } else { $file = JELIX_LIB_CORE_PATH . 'response/error.en_US.php'; } $HEADBOTTOM = ''; $BODYTOP = ''; $BODYBOTTOM = ''; $basePath = ''; header("HTTP/1.1 500 Internal jelix error"); header('Content-type: text/html'); include $file; } else { // output text response header("HTTP/1.1 500 Internal jelix error"); header('Content-type: text/plain'); echo 'Error during initialization.'; } } exit(1); }
/** * 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 jLogErrorMessage($type, $code, $message, $file, $line, $trace); $errorLog->setFormat(jApp::config()->error_handling['messageLogFormat']); jLog::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); }