diff options
author | Lukas Reschke <lukas@owncloud.com> | 2014-09-23 18:36:40 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2014-09-23 18:36:40 +0200 |
commit | 75e45ac78653198fc2575c39c533dc27c3003a0e (patch) | |
tree | 15d3cceed862c72efa5ead07cc352f85722c2935 /lib/public | |
parent | 89e02e89d4a0cf28a9318f4dacd070783cbb7531 (diff) | |
parent | c6eab9aaba3be7b77d543fde49fee889563fcd90 (diff) | |
download | nextcloud-server-75e45ac78653198fc2575c39c533dc27c3003a0e.tar.gz nextcloud-server-75e45ac78653198fc2575c39c533dc27c3003a0e.zip |
Merge pull request #11019 from owncloud/do-not-show-exception-to-enduser
Do not show exception to the end-user - use a proper error page instead
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 35847fce38a..e9a93849bfb 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -83,38 +83,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); } /** |