5 require_once
'Services/Environment/classes/class.ilRuntime.php';
19 include_once
'PEAR.php';
22 require_once(
"./Services/Exceptions/lib/Whoops/Run.php");
23 require_once(
"./Services/Exceptions/lib/Whoops/Handler/HandlerInterface.php");
24 require_once(
"./Services/Exceptions/lib/Whoops/Handler/Handler.php");
25 require_once(
"./Services/Exceptions/lib/Whoops/Handler/CallbackHandler.php");
26 require_once(
"./Services/Exceptions/lib/Whoops/Handler/PrettyPageHandler.php");
27 require_once(
"./Services/Exceptions/lib/Whoops/Exception/Inspector.php");
28 require_once(
"./Services/Exceptions/lib/Whoops/Exception/ErrorException.php");
29 require_once(
"./Services/Exceptions/lib/Whoops/Exception/FrameCollection.php");
30 require_once(
"./Services/Exceptions/lib/Whoops/Exception/Frame.php");
31 require_once(
"./Services/Exceptions/lib/Whoops/Exception/Inspector.php");
32 require_once(
"./Services/Exceptions/lib/Whoops/Exception/Formatter.php");
33 require_once(
"./Services/Exceptions/lib/Whoops/Util/TemplateHelper.php");
34 require_once(
"./Services/Exceptions/lib/Whoops/Util/Misc.php");
36 require_once(
"Services/Exceptions/classes/class.ilDelegatingHandler.php");
37 require_once(
"Services/Exceptions/classes/class.ilPlainTextHandler.php");
38 require_once(
"Services/Exceptions/classes/class.ilTestingHandler.php");
90 $this->DEBUG_ENV =
true;
95 $this->error_obj =
false;
109 if (self::$handlers_registered) {
119 if ($ilRuntime->shouldLogErrors()) {
120 $whoops->pushHandler($this->loggingHandler());
125 self::$handlers_registered =
true;
150 return $this->error_obj;
164 if ($a_error_obj->getCode() == null)
169 $this->error_obj =& $a_error_obj;
171 if (
$_SESSION[
"failure"] && substr($a_error_obj->getMessage(), 0, 22) !=
"Cannot find this block")
173 $m =
"Fatal Error: Called raise error two times.<br>".
174 "First error: ".$_SESSION[
"failure"].
'<br>'.
175 "Last Error:". $a_error_obj->getMessage();
178 #$log->writeWarning($m); 179 #$log->logError($a_error_obj->getCode(), $m); 184 if (substr($a_error_obj->getMessage(), 0, 22) ==
"Cannot find this block")
188 echo
"<b>DEVMODE</b><br><br>";
189 echo
"<b>Template Block not found.</b><br>";
190 echo
"You used a template block in your code that is not available.<br>";
191 echo
"Native Messge: <b>".$a_error_obj->getMessage().
"</b><br>";
192 if (is_array($a_error_obj->backtrace))
194 echo
"Backtrace:<br>";
195 foreach ($a_error_obj->backtrace as $b)
197 if ($b[
"function"] ==
"setCurrentBlock" &&
198 basename($b[
"file"]) !=
"class.ilTemplate.php")
202 echo
"File: ".$b[
"file"].
", ";
203 echo
"Line: ".$b[
"line"].
", ";
204 echo $b[
"function"].
"()<br>";
205 if ($b[
"function"] ==
"setCurrentBlock" &&
206 basename($b[
"file"]) !=
"class.ilTemplate.php")
217 if (is_object($log) and $log->enabled ==
true)
219 $log->write($a_error_obj->getMessage());
220 #$log->logError($a_error_obj->getCode(),$a_error_obj->getMessage()); 226 trigger_error(stripslashes($a_error_obj->getMessage()), E_USER_ERROR);
232 if ($this->DEBUG_ENV)
234 $message = $a_error_obj->getMessage();
238 $message =
"Under Construction";
243 if (!defined(
"ILIAS_MODULE"))
255 $_SESSION[
"failure"] = $a_error_obj->getMessage();
261 $dirname = dirname(
$_SERVER[
"PHP_SELF"]);
262 $ilurl = parse_url(ILIAS_HTTP_PATH);
263 $subdir = substr(strstr($dirname,$ilurl[
"path"]),strlen($ilurl[
"path"]));
268 $num_subdirs = substr_count($subdir,
"/");
270 for ($i=1;$i<=$num_subdirs;$i++)
296 return $this->message;
300 $this->message = $a_message;
306 $this->message .=
"<br /> ";
308 $this->message .= $a_message;
327 $ilLog->write(
'PHP errror: '.$errstr.
'. FATAL error on line '.$errline.
' in file '.$errfile);
332 $ilLog->write(
'PHP warning: ['.$errno.
'] '.$errstr.
' on line '.$errline.
' in file '.$errfile);
370 and $exception->getCode() == E_ERROR) {
372 $_SESSION[
"failure"] = $exception->getMessage();
373 include(
"error.php");
377 require_once(
"Services/Utilities/classes/class.ilUtil.php");
385 if (class_exists(
"ilInitialisation"))
387 ilInitialisation::initHTML();
389 include(
"error.php");
406 switch (ERROR_HANDLER) {
415 $ilLog->write(
"Unknown or undefined error handler '".ERROR_HANDLER.
"'. " 416 .
"Falling back to PrettyPageHandler.");
426 protected function loggingHandler() {
436 $log_message = $self->logMessageFor($exception, (
bool)LOG_ERROR_TRACE);
437 if(is_object($ilLog)) {
440 $ilLog->write($log_message, 300);
458 assert(
'is_bool($log_trace)');
459 $prefix =
"PHP Error: ";
461 switch ($exception->getCode()) {
464 $prefix =
"PHP Fatal error: ";
468 $msg = $prefix.$exception->getMessage().
" in ".$exception->getFile().
" on line ".$exception->getLine();
471 $msg .=
"\n".$exception->getTraceAsString();
logMessageFor(Exception $exception, $log_trace)
Get the error message to be logged.
isDevmodeActive()
Is the DEVMODE switched on?
initHandlers()
Initialize Error and Exception Handlers.
getWhoops()
Get an instance of Whoops/Run.
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
ilErrorHandling()
Constructor public.
appendMessage($a_message)
static $handlers_registered
defaultHandler()
Get a default error handler.
getIlRuntime()
Get ilRuntime.
PEAR($error_class=null)
Constructor.
getHandler()
Get a handler for an error or exception.
Whoops - php errors for cool kids.
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!!!
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
devmodeHandler()
Get the handler to be used in DEVMODE.
A Whoops error handler for testing.
Wrapper for Closures passed as handlers.
static redirect($a_script)
http redirect to other script