6 require_once
'Services/Environment/classes/class.ilRuntime.php';
22 require_once(
"Services/Exceptions/classes/class.ilDelegatingHandler.php");
23 require_once(
"Services/Exceptions/classes/class.ilPlainTextHandler.php");
24 require_once(
"Services/Exceptions/classes/class.ilTestingHandler.php");
25 set_include_path(
"./Services/Database/lib/PEAR" . PATH_SEPARATOR . ini_get(
'include_path'));
26 if (!class_exists(
'PEAR')) {
27 require_once
'PEAR.php';
76 parent::__construct();
79 $this->DEBUG_ENV =
true;
84 $this->error_obj =
false;
89 restore_error_handler();
90 set_error_handler(
array($this,
"handlePreWhoops"));
103 if (self::$whoops_handlers_registered) {
113 if ($ilRuntime->shouldLogErrors()) {
114 $this->whoops->pushHandler($this->loggingHandler());
117 $this->whoops->register();
119 self::$whoops_handlers_registered =
true;
145 return $this->error_obj;
159 if ($a_error_obj->getCode() == null) {
163 $this->error_obj =&$a_error_obj;
165 if (
$_SESSION[
"failure"] && substr($a_error_obj->getMessage(), 0, 22) !=
"Cannot find this block") {
166 $m =
"Fatal Error: Called raise error two times.<br>" .
167 "First error: " .
$_SESSION[
"failure"] .
'<br>' .
168 "Last Error:" . $a_error_obj->getMessage();
171 #$log->writeWarning($m); 172 #$log->logError($a_error_obj->getCode(), $m); 177 if (substr($a_error_obj->getMessage(), 0, 22) ==
"Cannot find this block") {
179 echo
"<b>DEVMODE</b><br><br>";
180 echo
"<b>Template Block not found.</b><br>";
181 echo
"You used a template block in your code that is not available.<br>";
182 echo
"Native Messge: <b>" . $a_error_obj->getMessage() .
"</b><br>";
183 if (is_array($a_error_obj->backtrace)) {
184 echo
"Backtrace:<br>";
185 foreach ($a_error_obj->backtrace as $b) {
186 if ($b[
"function"] ==
"setCurrentBlock" &&
187 basename($b[
"file"]) !=
"class.ilTemplate.php") {
190 echo
"File: " . $b[
"file"] .
", ";
191 echo
"Line: " . $b[
"line"] .
", ";
192 echo $b[
"function"] .
"()<br>";
193 if ($b[
"function"] ==
"setCurrentBlock" &&
194 basename($b[
"file"]) !=
"class.ilTemplate.php") {
204 if (is_object($log) and $log->enabled ==
true) {
205 $log->write($a_error_obj->getMessage());
206 #$log->logError($a_error_obj->getCode(),$a_error_obj->getMessage()); 211 trigger_error(stripslashes($a_error_obj->getMessage()), E_USER_ERROR);
216 if ($this->DEBUG_ENV) {
217 $message = $a_error_obj->getMessage();
224 if (!
defined(
"ILIAS_MODULE")) {
232 $_SESSION[
"failure"] = $a_error_obj->getMessage();
237 $dirname = dirname(
$_SERVER[
"PHP_SELF"]);
238 $ilurl = parse_url(ILIAS_HTTP_PATH);
239 $subdir = substr(strstr($dirname, $ilurl[
"path"]), strlen($ilurl[
"path"]));
243 $num_subdirs = substr_count($subdir,
"/");
245 for (
$i=1;
$i<=$num_subdirs;
$i++) {
274 $this->message = $a_message;
279 $this->message .=
"<br /> ";
281 $this->message .= $a_message;
299 $ilLog->write(
'PHP errror: ' . $errstr .
'. FATAL error on line ' . $errline .
' in file ' . $errfile);
304 $ilLog->write(
'PHP warning: [' . $errno .
'] ' . $errstr .
' on line ' . $errline .
' in file ' . $errfile);
335 return defined(
"DEVMODE") && (int) DEVMODE === 1;
348 require_once(
"Services/Logging/classes/error/class.ilLoggingErrorSettings.php");
349 require_once(
"Services/Logging/classes/error/class.ilLoggingErrorFileStorage.php");
350 require_once(
"Services/Utilities/classes/class.ilUtil.php");
352 $session_id = substr(session_id(), 0, 5);
353 $random = new \ilRandom();
354 $err_num = $random->int(1, 9999);
355 $file_name = $session_id .
"_" . $err_num;
358 if (!empty($logger->folder())) {
365 $lng->loadLanguageModule(
'logging');
366 $message = sprintf($lng->txt(
"log_error_message"), $file_name);
368 if ($logger->mail()) {
369 $message .=
" " . sprintf($lng->txt(
"log_error_message_send_mail"), $logger->mail(), $file_name, $logger->mail());
372 $message =
"Error " . $file_name .
" occurred.";
374 if ($logger->mail()) {
375 $message .=
' ' .
'Please send a mail to <a href="mailto:' . $logger->mail() .
'?subject=code: ' . $file_name .
'">' . $logger->mail() .
'%s</a>';
392 switch (ERROR_HANDLER) {
401 $ilLog->write(
"Unknown or undefined error handler '" . ERROR_HANDLER .
"'. " 402 .
"Falling back to PrettyPageHandler.");
412 protected function loggingHandler()
422 if (is_object($ilLog)) {
423 $message = $exception->getMessage() .
' in ' . $exception->getFile() .
":" . $exception->getLine();
424 $ilLog->error($exception->getCode() .
' ' .
$message);
436 if ($level & error_reporting()) {
440 if (version_compare(PHP_VERSION,
'7.0.0',
'<')) {
441 if ($level == E_STRICT) {
442 if (!stristr(
$message,
"should be compatible") &&
443 !stristr(
$message,
"should not be called statically") &&
444 !stristr(
$message,
"should not be abstract")) {
453 if ($level >= E_USER_NOTICE) {
455 $severity = Whoops\Util\Misc::TranslateErrorCode($level);
456 $ilLog->write(
"\n\n" . $severity .
" - " .
$message .
"\n" .
$file .
" - line " . $line .
"\n");
464 return $this->whoops->handleError($level,
$message,
$file, $line);
isDevmodeActive()
Is the DEVMODE switched on?
getWhoops()
Get an instance of Whoops/Run.
static $whoops_handlers_registered
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
__construct()
Constructor public.
appendMessage($a_message)
Saves error informations into file.
defaultHandler()
Get a default error handler.
getIlRuntime()
Get ilRuntime.
catch(Exception $e) $message
getHandler()
Get a handler for an error or exception.
errorHandler($a_error_obj)
defines what has to happen in case of error private
static _ilErrorWriter($errno, $errstr, $errfile, $errline)
This is used in Soap calls to write PHP error in ILIAS Logfile Not used yet!!!
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
handlePreWhoops($level, $message, $file, $line)
initWhoopsHandlers()
Initialize Error and Exception Handlers.
devmodeHandler()
Get the handler to be used in DEVMODE.
A Whoops error handler for testing.
Wrapper for Closures passed as handlers.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
static redirect($a_script)