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"));
102 if (self::$whoops_handlers_registered) {
112 if ($ilRuntime->shouldLogErrors()) {
113 $this->whoops->pushHandler($this->loggingHandler());
116 $this->whoops->register();
118 self::$whoops_handlers_registered =
true;
143 return $this->error_obj;
157 if ($a_error_obj->getCode() == null)
162 $this->error_obj =& $a_error_obj;
164 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")
181 echo "<b>DEVMODE</b><br><br>";
182 echo "<b>Template Block not found.</b><br>";
183 echo "You used a template block in your code that is not available.<br>";
184 echo "Native Messge: <b>".$a_error_obj->getMessage().
"</b><br>";
185 if (is_array($a_error_obj->backtrace))
187 echo "Backtrace:<br>";
188 foreach ($a_error_obj->backtrace as $b)
190 if ($b[
"function"] ==
"setCurrentBlock" &&
191 basename($b[
"file"]) !=
"class.ilTemplate.php")
195 echo "File: ".$b[
"file"].
", ";
196 echo "Line: ".$b[
"line"].
", ";
197 echo $b[
"function"].
"()<br>";
198 if ($b[
"function"] ==
"setCurrentBlock" &&
199 basename($b[
"file"]) !=
"class.ilTemplate.php")
210 if (is_object($log)
and $log->enabled ==
true)
212 $log->write($a_error_obj->getMessage());
213 #$log->logError($a_error_obj->getCode(),$a_error_obj->getMessage()); 219 trigger_error(stripslashes($a_error_obj->getMessage()), E_USER_ERROR);
225 if ($this->DEBUG_ENV)
227 $message = $a_error_obj->getMessage();
231 $message =
"Under Construction";
248 $_SESSION[
"failure"] = $a_error_obj->getMessage();
254 $dirname = dirname(
$_SERVER[
"PHP_SELF"]);
255 $ilurl = parse_url(ILIAS_HTTP_PATH);
256 $subdir = substr(strstr($dirname,$ilurl[
"path"]),strlen($ilurl[
"path"]));
261 $num_subdirs = substr_count($subdir,
"/");
263 for ($i=1;$i<=$num_subdirs;$i++)
289 return $this->message;
293 $this->message = $a_message;
299 $this->message .=
"<br /> ";
301 $this->message .= $a_message;
320 $ilLog->write(
'PHP errror: '.$errstr.
'. FATAL error on line '.$errline.
' in file '.$errfile);
325 $ilLog->write(
'PHP warning: ['.$errno.
'] '.$errstr.
' on line '.$errline.
' in file '.$errfile);
365 require_once(
"Services/Logging/classes/error/class.ilLoggingErrorSettings.php");
366 require_once(
"Services/Logging/classes/error/class.ilLoggingErrorFileStorage.php");
367 require_once(
"Services/Utilities/classes/class.ilUtil.php");
369 $session_id = substr(session_id(),0,5);
370 $err_num = rand(1, 9999);
371 $file_name = $session_id.
"_".$err_num;
374 if(!empty($logger->folder())) {
381 $lng->loadLanguageModule(
'logging');
382 $message = sprintf($lng->txt(
"log_error_message"), $file_name);
384 if($logger->mail()) {
385 $message .=
" ".sprintf($lng->txt(
"log_error_message_send_mail"), $logger->mail(), $file_name, $logger->mail());
388 $message =
"Error ".$file_name.
" occurred.";
390 if($logger->mail()) {
391 $message .=
' '.
'Please send a mail to <a href="mailto:'.$logger->mail().
'?subject=code: '.$file_name.
'">'.$logger->mail().
'%s</a>';
407 switch (ERROR_HANDLER) {
416 $ilLog->write(
"Unknown or undefined error handler '".ERROR_HANDLER.
"'. " 417 .
"Falling back to PrettyPageHandler.");
427 protected function loggingHandler() {
436 if(is_object($ilLog)) {
437 $message = $exception->getMessage().
' in '.$exception->getFile().
":".$exception->getLine();
438 $ilLog->error($exception->getCode().
' '.$message);
450 if ($level & error_reporting()) {
454 if (version_compare(PHP_VERSION,
'7.0.0',
'<')) {
455 if ($level == E_STRICT) {
456 if (!stristr($message,
"should be compatible") &&
457 !stristr($message,
"should not be called statically") &&
458 !stristr($message,
"should not be abstract")) {
467 if ($level >= E_USER_NOTICE) {
470 $severity = Whoops\Util\Misc::TranslateErrorCode($level);
471 $ilLog->write(
"\n\n".$severity.
" - ".$message.
"\n".
$file.
" - line ".$line.
"\n");
480 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.
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)
http redirect to other script