mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-06-20 22:00:15 +02:00
parent
d0aa39007a
commit
ff6fbdf5f2
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
namespace Icinga\Controllers;
|
namespace Icinga\Controllers;
|
||||||
|
|
||||||
|
use Icinga\Exception\IcingaException;
|
||||||
use Zend_Controller_Plugin_ErrorHandler;
|
use Zend_Controller_Plugin_ErrorHandler;
|
||||||
use Icinga\Application\Icinga;
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Application\Logger;
|
use Icinga\Application\Logger;
|
||||||
@ -83,7 +84,7 @@ class ErrorController extends ActionController
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->getResponse()->setHttpResponseCode(500);
|
$this->getResponse()->setHttpResponseCode(500);
|
||||||
Logger::error("%s\n%s", $exception, $exception->getTraceAsString());
|
Logger::error("%s\n%s", $exception, IcingaException::getConfidentialTraceAsString($exception));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +95,7 @@ class ErrorController extends ActionController
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
$this->view->messages[] = $exception->getMessage();
|
$this->view->messages[] = $exception->getMessage();
|
||||||
$this->view->stackTraces[] = $exception->getTraceAsString();
|
$this->view->stackTraces[] = IcingaException::getConfidentialTraceAsString($exception);
|
||||||
$exception = $exception->getPrevious();
|
$exception = $exception->getPrevious();
|
||||||
} while ($exception !== null);
|
} while ($exception !== null);
|
||||||
} else {
|
} else {
|
||||||
|
@ -60,4 +60,44 @@ class IcingaException extends Exception
|
|||||||
$exception->getMessage()
|
$exception->getMessage()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the same as {@link Exception::getTraceAsString()} for the given exception,
|
||||||
|
* but show only the types of scalar arguments
|
||||||
|
*
|
||||||
|
* @param Exception $exception
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getConfidentialTraceAsString(Exception $exception)
|
||||||
|
{
|
||||||
|
$trace = array();
|
||||||
|
|
||||||
|
foreach ($exception->getTrace() as $index => $frame) {
|
||||||
|
$trace[] = "#{$index} {$frame['file']}({$frame['line']}): ";
|
||||||
|
|
||||||
|
if (isset($frame['class'])) {
|
||||||
|
$trace[] = $frame['class'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($frame['type'])) {
|
||||||
|
$trace[] = $frame['type'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$trace[] = "{$frame['function']}(";
|
||||||
|
|
||||||
|
$args = array();
|
||||||
|
foreach ($frame['args'] as $arg) {
|
||||||
|
$type = gettype($arg);
|
||||||
|
$args[] = $type === 'object' ? 'Object(' . get_class($arg) . ')' : ucfirst($type);
|
||||||
|
}
|
||||||
|
|
||||||
|
$trace[] = implode(', ', $args);
|
||||||
|
$trace[] = ")\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$trace[] = '#' . ($index + 1) . ' {main}';
|
||||||
|
|
||||||
|
return implode($trace);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
namespace Icinga\Module\Doc\Renderer;
|
namespace Icinga\Module\Doc\Renderer;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use Icinga\Exception\IcingaException;
|
||||||
use RecursiveIteratorIterator;
|
use RecursiveIteratorIterator;
|
||||||
use Icinga\Application\Icinga;
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Web\View;
|
use Icinga\Web\View;
|
||||||
@ -201,7 +202,7 @@ abstract class DocRenderer extends RecursiveIteratorIterator
|
|||||||
try {
|
try {
|
||||||
return $this->render();
|
return $this->render();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
return $e->getMessage() . ': ' . $e->getTraceAsString();
|
return $e->getMessage() . ': ' . IcingaException::getConfidentialTraceAsString($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user