From: Tim Düsterhus Date: Tue, 17 Apr 2012 18:21:06 +0000 (+0200) Subject: Add error-ids to SystemException X-Git-Tag: 2.0.0_Beta_1~1151^2^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e58c14dda44c022ab8f77761417ef228cc30700d;p=GitHub%2FWoltLab%2FWCF.git Add error-ids to SystemException --- diff --git a/wcfsetup/install/files/lib/system/exception/LoggedException.class.php b/wcfsetup/install/files/lib/system/exception/LoggedException.class.php index 2b7643414b..7bfa98e8f1 100644 --- a/wcfsetup/install/files/lib/system/exception/LoggedException.class.php +++ b/wcfsetup/install/files/lib/system/exception/LoggedException.class.php @@ -1,13 +1,14 @@ * @package com.woltlab.wcf * @subpackage system.exception @@ -50,10 +51,23 @@ class LoggedException extends \Exception { } $e = ($this->getPrevious() ?: $this); - // build message - $message = date('r', TIME_NOW) . "\n" . $e->getMessage() . "\n\n" . $e->getTraceAsString() . "\n\n\n"; + + $message = date('r', TIME_NOW)."\n". + 'Message: '.$e->getMessage()."\n". + 'File: '.$e->getFile().' ('.$e->getLine().")\n". + 'PHP version: '.phpversion()."\n". + 'WCF version: '.WCF_VERSION."\n". + 'Request URI: '.(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '')."\n". + 'Referrer: '.(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '')."\n". + "Stacktrace: \n ".implode("\n ", explode("\n", $e->getTraceAsString()))."\n"; + + // calculate Exception-ID + $id = StringUtil::getHash($message); + $message = "<<<<<<<<".$id."<<<<\n".$message."<<<<\n\n"; // append @file_put_contents($logFile, $message, FILE_APPEND); + + return $id; } } diff --git a/wcfsetup/install/files/lib/system/exception/SystemException.class.php b/wcfsetup/install/files/lib/system/exception/SystemException.class.php index faa15071fd..f4ae20345f 100644 --- a/wcfsetup/install/files/lib/system/exception/SystemException.class.php +++ b/wcfsetup/install/files/lib/system/exception/SystemException.class.php @@ -70,7 +70,7 @@ class SystemException extends LoggedException implements IPrintableException { */ public function show() { // log error - $this->logError(); + $exceptionID = $this->logError(); // send status code @header('HTTP/1.1 503 Service Unavailable'); @@ -153,9 +153,10 @@ class SystemException extends LoggedException implements IPrintableException {

getDescription(); ?>

- +

Information:

+ id:
error message: _getMessage()); ?>
error code: getCode()); ?>
information; ?> @@ -166,12 +167,20 @@ class SystemException extends LoggedException implements IPrintableException { request:
referer:

- +

Stacktrace:

__getTraceAsString()); ?>
+ +
+

Information:

+

+ id:
+ Send this ID to the administrator of this website to report this issue. +

+
- + functions; ?>