Expand exception stack trace in log in debug mode
This commit is contained in:
parent
0641365a10
commit
83956b1703
31
index.php
31
index.php
|
@ -23,6 +23,34 @@
|
||||||
|
|
||||||
$RUNTIME_NOAPPS = true; //no apps, yet
|
$RUNTIME_NOAPPS = true; //no apps, yet
|
||||||
|
|
||||||
|
function logException($ex) {
|
||||||
|
$message = $ex->getMessage();
|
||||||
|
if ($ex->getCode()) {
|
||||||
|
$message .= ' [' . $message . ']';
|
||||||
|
}
|
||||||
|
\OCP\Util::writeLog('index', $message, \OCP\Util::FATAL);
|
||||||
|
if (defined('DEBUG') and DEBUG) {
|
||||||
|
// also log stack trace
|
||||||
|
$stack = explode('#', $ex->getTraceAsString());
|
||||||
|
// first element is empty
|
||||||
|
array_shift($stack);
|
||||||
|
foreach ($stack as $s) {
|
||||||
|
\OCP\Util::writeLog('index', $s, \OCP\Util::FATAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// include cause
|
||||||
|
$l = OC_L10N::get('lib');
|
||||||
|
while (method_exists($ex, 'getPrevious') && $ex = $ex->getPrevious()) {
|
||||||
|
$message .= ' - '.$l->t('Caused by:').' ';
|
||||||
|
$message .= $ex->getMessage();
|
||||||
|
if ($ex->getCode()) {
|
||||||
|
$message .= '['.$ex->getCode().'] ';
|
||||||
|
}
|
||||||
|
\OCP\Util::writeLog('index', $message, \OCP\Util::FATAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
require_once 'lib/base.php';
|
require_once 'lib/base.php';
|
||||||
|
@ -30,8 +58,9 @@ try {
|
||||||
OC::handleRequest();
|
OC::handleRequest();
|
||||||
|
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
|
logException($ex);
|
||||||
|
|
||||||
//show the user a detailed error page
|
//show the user a detailed error page
|
||||||
\OCP\Util::writeLog('index', $ex->getMessage(), \OCP\Util::FATAL);
|
|
||||||
OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
|
OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
|
||||||
OC_Template::printExceptionErrorPage($ex);
|
OC_Template::printExceptionErrorPage($ex);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue