/** * @link http://php.net/manual/en/function.register-shutdown-function.php */ public function onExit() { $error = error_get_last(); if (null !== $error) { $this->onError($error['type'], $error['message'], $error['file'], $error['line']); } if (self::$m_isCli) { $hasErrors = 0 < count(self::$m_exceptions); foreach (self::$m_exceptions as $exception) { exception_print_cli($exception, true, true); } if (false === @is_file(self::$m_cacheFile)) { Cache::dump(self::$m_cacheFile); } exit(false === $hasErrors ? 0 : -1); } if (Debug::active() && (self::isManagementAccess() || Environment::isDev())) { if (0 < count(self::$m_exceptions)) { Debug::verror(self::$m_exceptions); } Debug::flush(); self::$m_exceptions = []; } if (false === Environment::isDev()) { self::$m_exceptions = []; } foreach (self::$m_exceptions as $exception) { exception_print_html($exception, true, true); } }
/** * Render & print plain text formatted details for given exception. * * @param \Exception $e_ * @param bool $includeSource_ * @param bool $includeStackTrace_ */ function exception_print_cli(\Exception $e_, $includeSource_ = false, $includeStackTrace_ = false) { $type = Components\Type::of($e_); printf(' [%1$s] %2$s in %4$s %6$s %3$s %6$s %5$s %6$s', \math\hasho_md5($e_), $type->name(), $e_->getMessage(), $includeSource_ ? implode(':', [$e_->getFile(), $e_->getLine()]) : '', $includeStackTrace_ ? $e_->getTraceAsString() : '', PHP_EOL); if ($cause = $e_->getPrevious()) { exception_print_cli($cause, $includeSource_, $includeStackTrace_); } }