19 declare(strict_types=1);
    45         'usr_password_retype',
    47         'new_password_retype',
    78         $this->DEBUG_ENV = 
true;
    86         restore_error_handler();
    87         set_error_handler([$this, 
'handlePreWhoops']);
    97         if (self::$whoops_handlers_registered) {
   103         $this->whoops->pushHandler(
new ilDelegatingHandler($this, self::SENSTIVE_PARAMETER_NAMES));
   104         if ($ilRuntime->shouldLogErrors()) {
   105             $this->whoops->pushHandler($this->loggingHandler());
   107         $this->whoops->register();
   108         self::$whoops_handlers_registered = 
true;
   118             strcasecmp(
$_SERVER[
'REQUEST_METHOD'] ?? 
'', 
'post') === 0) {
   135         $backtrace = debug_backtrace();
   136         if (isset($backtrace[0], $backtrace[0][
'object'])) {
   137             unset($backtrace[0][
'object']);
   142         $this->
errorHandler($message, $code ?? $this->WARNING, $backtrace);
   148     private function errorHandler(
string $message, 
int $code, array $backtrace): void
   153         if ($session_failure && strpos($message, 
'Cannot find this block') !== 0) {
   154             $m = 
'Fatal Error: Called raise error two times.<br>' .
   155                 'First error: ' . $session_failure . 
'<br>' .
   162         if (strpos($message, 
'Cannot find this block') === 0) {
   163             if (defined(
'DEVMODE') && DEVMODE) {
   164                 echo 
'<b>DEVMODE</b><br><br>';
   165                 echo 
'<b>Template Block not found.</b><br>';
   166                 echo 
'You used a template block in your code that is not available.<br>';
   167                 echo 
'Native Messge: <b>' . $message . 
'</b><br>';
   168                 echo 
'Backtrace:<br>';
   169                 foreach ($backtrace as 
$b) {
   170                     if ($b[
'function'] === 
'setCurrentBlock' &&
   171                         basename($b[
'file']) !== 
'class.ilTemplate.php') {
   174                     echo 
'File: ' . $b[
'file'] . 
', ';
   175                     echo 
'Line: ' . $b[
'line'] . 
', ';
   176                     echo $b[
'function'] . 
'()<br>';
   177                     if ($b[
'function'] === 
'setCurrentBlock' &&
   178                         basename($b[
'file']) !== 
'class.ilTemplate.php') {
   188             $log->write($message);
   190         if ($code === $this->FATAL) {
   191             trigger_error(stripslashes($message), E_USER_ERROR);
   195         if ($code === $this->WARNING) {
   196             if (!$this->DEBUG_ENV) {
   197                 $message = 
'Under Construction';
   202             if (!defined(
'ILIAS_MODULE')) {
   209         if ($code === $this->MESSAGE) {
   212             $_SESSION[
'error_post_vars'] = 
$_POST;
   214             if (empty($_SESSION[
'referer'])) {
   215                 $dirname = dirname(
$_SERVER[
'PHP_SELF']);
   219                 if (is_array($ilurl) && array_key_exists(
'path', $ilurl) && $ilurl[
'path'] !== 
'') {
   220                     $subdir = substr(strstr($dirname, (
string) $ilurl[
'path']), strlen((
string) $ilurl[
'path']));
   224                     $num_subdirs = substr_count($subdir, 
'/');
   226                     for ($i = 1; $i <= $num_subdirs; $i++) {
   243         $this->message = $a_message;
   249             $this->message .= 
'<br /> ';
   251         $this->message .= $a_message;
   266         return defined(
'DEVMODE') && (
int) DEVMODE === 1;
   271         return new CallbackHandler(
function ($exception, Inspector $inspector, Run $run) {
   274             $session_id = substr(session_id(), 0, 5);
   275             $r = new \Random\Randomizer();
   276             $err_num = 
$r->getInt(1, 9999);
   277             $file_name = $session_id . 
'_' . $err_num;
   280             if (!empty($logger->folder())) {
   287             if ($DIC->isDependencyAvailable(
'language')) {
   288                 $DIC->language()->loadLanguageModule(
'logging');
   289                 $message = sprintf($DIC->language()->txt(
'log_error_message'), $file_name);
   291                 if ($logger->mail()) {
   292                     $message .= 
' ' . sprintf(
   293                         $DIC->language()->txt(
'log_error_message_send_mail'),
   300                 $message = 
'Sorry, an error occured. A logfile has been created which can be identified via the code "' . $file_name . 
'"';
   302                 if ($logger->mail()) {
   303                     $message .= 
' ' . 
'Please send a mail to <a href="mailto:' . $logger->mail() . 
'?subject=code: ' . $file_name . 
'">' . $logger->mail() . 
'</a>';
   306             if ($DIC->isDependencyAvailable(
'ui') && isset($DIC[
'tpl']) && $DIC->isDependencyAvailable(
'ctrl')) {
   307                 $DIC->ui()->mainTemplate()->setOnScreenMessage(
'failure', $message, 
true);
   308                 $DIC->ctrl()->redirectToURL(
'error.php');
   311                 header(
'Location: error.php');
   321         switch (ERROR_HANDLER) {
   323                 return (
new ilTestingHandler())->withExclusionList(self::SENSTIVE_PARAMETER_NAMES);
   331                 if ((!defined(
'ERROR_HANDLER') || ERROR_HANDLER !== 
'PRETTY_PAGE') && $ilLog) {
   333                         "Unknown or undefined error handler '" . ERROR_HANDLER . 
"'. " .
   334                         'Falling back to PrettyPageHandler.'   338                 $prettyPageHandler = 
new PrettyPageHandler();
   342                 foreach (self::SENSTIVE_PARAMETER_NAMES as 
$param) {
   343                     $prettyPageHandler->blacklist(
'_POST', $param);
   346                 return $prettyPageHandler;
   352         $editorUrl = defined(
'ERROR_EDITOR_URL') ? ERROR_EDITOR_URL : 
'';
   353         if (!is_string($editorUrl) || $editorUrl === 
'') {
   357         $pathTranslationConfig = defined(
'ERROR_EDITOR_PATH_TRANSLATIONS') ? ERROR_EDITOR_PATH_TRANSLATIONS : 
'';
   361         $handler->setEditor(
function ($file, $line) use ($editorUrl, $pathTranslations) {
   365                 [
'[FILE]', 
'[LINE]'],
   374         foreach ($pathTranslations as $from => $to) {
   375             $file = preg_replace(
'@' . $from . 
'@', $to, $file);
   381         $pathTranslations = [];
   383         $mappings = explode(
'|', $pathTranslationConfig);
   384         foreach ($mappings as $mapping) {
   385             $parts = explode(
',', $mapping);
   386             if (count(
$parts) === 2) {
   391         return $pathTranslations;
   394     protected function loggingHandler(): HandlerInterface
   396         return new CallbackHandler(
function ($exception, Inspector $inspector, Run $run) {
   403             if (is_object($ilLog)) {
   404                 $message = $exception->getMessage() . 
' in ' . $exception->getFile() . 
':' . $exception->getLine();
   405                 $message .= $exception->getTraceAsString();
   407                 $previous = $exception->getPrevious();
   409                     $message .= 
"\n\nCaused by\n" . sprintf(
   410                         '%s: %s in file %s on line %d',
   411                         get_class($previous),
   412                         $previous->getMessage(),
   413                         $previous->getFile(),
   416                     $previous = $previous->getPrevious();
   419                 $ilLog->error($exception->getCode() . 
' ' . 
$message);
   423             error_log($exception->getMessage());
   431     public function handlePreWhoops(
int $level, 
string $message, 
string $file, 
int $line): bool
   435         if ($level & error_reporting()) {
   438                 if ($level >= E_USER_NOTICE) {
   440                         $severity = Whoops\Util\Misc::translateErrorCode($level);
   441                         $ilLog->write(
"\n\n" . $severity . 
' - ' . $message . 
"\n" . $file . 
' - line ' . $line . 
"\n");
   447             if ($this->whoops instanceof RunInterface) {
   448                 return $this->whoops->handleError($level, $message, $file, $line);
 
parseEditorPathTranslation(string $pathTranslationConfig)
 
static get(string $a_var)
 
int $MESSAGE
Error level 3: show message in recent page. 
 
errorHandler(string $message, int $code, array $backtrace)
 
setMessage(string $a_message)
 
int $FATAL
Error level 1: exit application immedietly. 
 
withExclusionList(array $exclusion_list)
 
int $WARNING
Error level 2: show warning page. 
 
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
 
A Whoops error handler that delegates calls on it self to another handler that is created only in the...
 
appendMessage(string $a_message)
 
addEditorSupport(PrettyPageHandler $handler)
 
const SENSTIVE_PARAMETER_NAMES
 
raiseError(string $message, ?int $code)
 
getHandler()
Get a handler for an error or exception. 
 
A Whoops error handler that prints the same content as the PrettyPageHandler but as plain text...
 
static redirect(string $a_script)
 
initWhoopsHandlers()
Initialize Error and Exception Handlers. 
 
applyEditorPathTranslations(string &$file, array $pathTranslations)
 
A Whoops error handler for testing. 
 
static bool $whoops_handlers_registered
 
static getType()
Get context type. 
 
static clear(string $a_var)
 
static set(string $a_var, $a_val)
Set a value. 
 
handlePreWhoops(int $level, string $message, string $file, int $line)
Parameter types according to PHP doc: set_error_handler.