Example #1
0
 /**
  * Like self::atkdebug, this displays a message at the bottom of the screen.
  * The difference is, that this is also displayed when debugging is turned
  * off.
  *
  * If error reporting by email is turned on, the error messages are also
  * send by e-mail.
  *
  * @param string|Exception $error the error self::text or exception to display
  * @param bool $skipThrow
  *
  * @throws \Exception if throw_exception_on_error
  */
 public static function atkerror($error, $skipThrow = false)
 {
     global $g_error_msg, $g_debug_msg;
     if ($error instanceof \Exception) {
         $g_error_msg[] = '[' . Debugger::elapsed() . '] ' . $error->getMessage();
         self::atkdebug(nl2br($error->getMessage() . "\n" . $error->getTraceAsString()), self::DEBUG_ERROR);
     } else {
         $g_error_msg[] = '[' . Debugger::elapsed() . '] ' . $error;
         self::atkdebug($error, self::DEBUG_ERROR);
     }
     if (function_exists('debug_backtrace')) {
         self::atkdebug('Trace:' . self::atkGetTrace(), self::DEBUG_ERROR);
     }
     $default_error_handlers = [];
     $mailReport = Config::getGlobal('mailreport');
     if ($mailReport) {
         $default_error_handlers['Mail'] = array('mailto' => $mailReport);
     }
     $errorHandlers = Config::getGlobal('error_handlers', $default_error_handlers);
     foreach ($errorHandlers as $key => $value) {
         if (is_numeric($key)) {
             $key = $value;
         }
         $errorHandlerObject = ErrorHandlerBase::get($key, $value);
         $errorHandlerObject->handle($g_error_msg, $g_debug_msg);
     }
     if (!$skipThrow && Config::getGlobal('throw_exception_on_error')) {
         if ($error instanceof Exception) {
             throw $error;
         } else {
             throw new Exception($error);
         }
     }
 }