diff options
author | Lukas Reschke <lukas@owncloud.com> | 2014-09-11 14:14:02 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2014-09-17 13:17:52 +0200 |
commit | 6d3757f8648cb94b2ba04c6a5bfbc9dd1493103b (patch) | |
tree | 0cef084c3140b52a4ced70acc6ede3eb52cf33ab /lib/public | |
parent | 45b17207ccf03703d4d6c3925f5405f52579aee5 (diff) | |
download | nextcloud-server-6d3757f8648cb94b2ba04c6a5bfbc9dd1493103b.tar.gz nextcloud-server-6d3757f8648cb94b2ba04c6a5bfbc9dd1493103b.zip |
Do not show exception to the end-user
Log the error instead of potentially leaking sensitive information
Diffstat (limited to 'lib/public')
-rw-r--r-- | lib/public/util.php | 38 |
1 files changed, 10 insertions, 28 deletions
diff --git a/lib/public/util.php b/lib/public/util.php index 244c11ba2cc..a0118e41cc4 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -82,38 +82,20 @@ class Util { } /** - * write exception into the log. Include the stack trace - * if DEBUG mode is enabled + * write exception into the log * @param string $app app name * @param \Exception $ex exception to log - * @param string $level log level, defaults to \OCP\Util::FATAL + * @param int $level log level, defaults to \OCP\Util::FATAL */ public static function logException( $app, \Exception $ex, $level = \OCP\Util::FATAL ) { - $class = get_class($ex); - $message = $class . ': ' . $ex->getMessage(); - if ($ex->getCode()) { - $message .= ' [' . $ex->getCode() . ']'; - } - \OCP\Util::writeLog($app, $message, $level); - if (defined('DEBUG') and DEBUG) { - // also log stack trace - $stack = explode("\n", $ex->getTraceAsString()); - // first element is empty - array_shift($stack); - foreach ($stack as $s) { - \OCP\Util::writeLog($app, 'Exception: ' . $s, $level); - } - - // include cause - while (method_exists($ex, 'getPrevious') && $ex = $ex->getPrevious()) { - $message .= ' - Caused by:' . ' '; - $message .= $ex->getMessage(); - if ($ex->getCode()) { - $message .= '[' . $ex->getCode() . '] '; - } - \OCP\Util::writeLog($app, 'Exception: ' . $message, $level); - } - } + $exception = array( + 'Message' => $ex->getMessage(), + 'Code' => $ex->getCode(), + 'Trace' => $ex->getTraceAsString(), + 'File' => $ex->getFile(), + 'Line' => $ex->getLine(), + ); + \OCP\Util::writeLog($app, 'Exception: ' . json_encode($exception), $level); } /** |