예제 #1
0
 public function build()
 {
     $this->doc = new \DOMDocument('1.0', 'UTF-8');
     $dom_root = $this->doc->createElement('document');
     $dom_root->setAttribute('debug', $this->getConfigValue('site.debug'));
     $dom_root->setAttribute('url', (string) E()->getRequest()->getURI());
     $this->doc->appendChild($dom_root);
     $dom_documentProperties = $this->doc->createElement('properties');
     $dom_root->appendChild($dom_documentProperties);
     $prop = $this->doc->createElement('property', E()->getSiteManager()->getCurrentSite()->base);
     $prop->setAttribute('name', 'base');
     $prop->setAttribute('folder', E()->getSiteManager()->getCurrentSite()->folder);
     $dom_documentProperties->appendChild($prop);
     $prop = $this->doc->createElement('property', $langID = E()->getLanguage()->getCurrent());
     $prop->setAttribute('name', 'lang');
     $prop->setAttribute('abbr', E()->getRequest()->getLangSegment());
     $prop->setAttribute('real_abbr', E()->getLanguage()->getAbbrByID($langID));
     $dom_documentProperties->appendChild($prop);
     unset($prop);
     $result = $this->doc->createElement('errors');
     $result->setAttribute('xml:id', 'result');
     $dom_root->appendChild($result);
     $vm = E()->getController()->getViewMode();
     if ($vm == DocumentController::TRANSFORM_JSON) {
         $errors = [['message' => $this->e->getMessage()]];
         $data = ['result' => false, 'errors' => $errors];
         $result->appendChild(new \DOMText(json_encode($data)));
     } else {
         $error = $this->doc->createElement('error');
         $result->appendChild($error);
         $error->appendChild($this->doc->createElement('message', $this->e->getMessage()));
         $error->setAttribute('file', $this->e->getFile());
         $error->setAttribute('line', $this->e->getLine());
         $bktrace = $this->doc->createElement('backtrace');
         $dbgObj = debug_backtrace(!DEBUG_BACKTRACE_PROVIDE_OBJECT, 5);
         array_walk($dbgObj, function ($callable) use($bktrace) {
             $bktrace->appendChild($call = $this->doc->createElement('call'));
             array_walk($callable, function ($value, $key) use($call) {
                 if (is_scalar($value)) {
                     $call->appendChild($this->doc->createElement($key, $value));
                 } elseif (is_array($value)) {
                     foreach ($value as $k1 => $v1) {
                         if (!is_scalar($v1)) {
                             $v1 = '[...]';
                         }
                         $call->appendChild($this->doc->createElement($key, $v1));
                     }
                 }
             });
         });
         $result->appendChild($bktrace);
         if ($vm == DocumentController::TRANSFORM_HTML) {
             E()->getController()->getTransformer()->setFileName('error_page.xslt');
         }
     }
 }
예제 #2
0
파일: errors.php 프로젝트: rboyatt/mahara
/**
 * Catches all otherwise uncaught exceptions. Will be deliberately used in some
 * situations. After this is called the script will end, so make sure to catch
 * any exceptions that you can deal with.
 *
 * @param Exception $e The exception that was thrown.
 * @access private
 */
function exception(Exception $e)
{
    global $USER;
    if ($USER) {
        if (!$e instanceof MaharaException || get_class($e) == 'MaharaException') {
            log_warn("An exception was thrown of class " . get_class($e) . ". \nTHIS IS BAD " . "and should be changed to something extending MaharaException,\n" . "unless the exception is from a third party library.\n" . "Original trace follows", true, false);
            log_message($e->getMessage(), LOG_LEVEL_WARN, true, true, $e->getFile(), $e->getLine(), $e->getTrace());
            $e = new SystemException($e->getMessage());
            $e->set_log_off();
        }
    }
    // Display the message and die
    $e->handle_exception();
}
 /**
  * Displays a system exception in the paackageinstallation exception template.
  * 
  * @param 	SystemException		$e
  */
 protected function showPackageInstallationException(SystemException $e)
 {
     $dbException = false;
     $sqlError = '';
     $sqlErrorNumber = 0;
     $sqlVersion = '';
     if ($e instanceof DatabaseException) {
         $dbException = true;
         $sqlError = $e->getErrorDesc();
         $sqlErrorNumber = $e->getErrorNumber();
         $sqlVersion = $e->getSQLVersion();
     }
     WCF::getTPL()->assign(array('dbException' => $dbException, 'sqlError' => $sqlError, 'sqlErrorNumber' => $sqlErrorNumber, 'sqlVersion' => $sqlVersion, 'errorMessage' => $e->getMessage(), 'errorDescription' => $e->getDescription(), 'phpVersion' => phpversion(), 'wcfVersion' => WCF_VERSION, 'file' => $e->getFile() . ' (' . $e->getLine() . ')', 'errorCode' => $e->getCode(), 'date' => gmdate('m/d/Y h:ia'), 'requestUri' => isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '', 'httpReferer' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '', 'stackTrace' => $e->getTraceAsString()));
     WCF::getTPL()->append(array('packageName' => ''));
     WCF::getTPL()->display('packageInstallationException');
     exit;
 }