From e58c14dda44c022ab8f77761417ef228cc30700d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 17 Apr 2012 20:21:06 +0200 Subject: [PATCH] Add error-ids to SystemException --- .../exception/LoggedException.class.php | 22 +++++++++++++++---- .../exception/SystemException.class.php | 17 ++++++++++---- 2 files changed, 31 insertions(+), 8 deletions(-) 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; ?> -- 2.20.1