mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 10:38:45 +02:00
🔊 N°3811 UI.php : update error log
We had 2 catch blocks that were doing almost the same thing... But the last IssueLog call ! Now we have only one catch block, and the last IssueLog call is for Debug instead of Error : ErrorPage::error is already doing IssueLog::Error, so those extra info are now logged only for debugging purpose (in the 'console' channel)
This commit is contained in:
83
pages/UI.php
83
pages/UI.php
@@ -1917,82 +1917,43 @@ EOF
|
||||
DisplayWelcomePopup($oP);
|
||||
$oP->output();
|
||||
}
|
||||
catch(CoreException $e)
|
||||
{
|
||||
require_once(APPROOT.'/setup/setuppage.class.inc.php');
|
||||
$oP = new ErrorPage(Dict::S('UI:PageTitle:FatalError'));
|
||||
if ($e instanceof SecurityException)
|
||||
{
|
||||
$oP->add("<h1>".Dict::S('UI:SystemIntrusion')."</h1>\n");
|
||||
catch (Exception $e) {
|
||||
$oErrorPage = new ErrorPage(Dict::S('UI:PageTitle:FatalError'));
|
||||
if ($e instanceof SecurityException) {
|
||||
$oErrorPage->add("<h1>".Dict::S('UI:SystemIntrusion')."</h1>\n");
|
||||
} else {
|
||||
$oErrorPage->add("<h1>".Dict::S('UI:FatalErrorMessage')."</h1>\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
$oP->add("<h1>".Dict::S('UI:FatalErrorMessage')."</h1>\n");
|
||||
}
|
||||
$oP->error(Dict::Format('UI:Error_Details', $e->getHtmlDesc()));
|
||||
$oP->output();
|
||||
$sErrorDetails = ($e instanceof CoreException) ? $e->getHtmlDesc() : $e->getMessage();
|
||||
$oErrorPage->error(Dict::Format('UI:Error_Details', $sErrorDetails));
|
||||
$oErrorPage->output();
|
||||
|
||||
if (MetaModel::IsLogEnabledIssue())
|
||||
{
|
||||
if (MetaModel::IsValidClass('EventIssue'))
|
||||
{
|
||||
try
|
||||
{
|
||||
$sErrorStackTrace = ($e instanceof CoreException) ? $e->getFullStackTraceAsString() : $e->getTraceAsString();
|
||||
if (MetaModel::IsLogEnabledIssue()) {
|
||||
if (MetaModel::IsValidClass('EventIssue')) {
|
||||
try {
|
||||
$oLog = new EventIssue();
|
||||
|
||||
|
||||
$oLog->Set('message', $e->getMessage());
|
||||
$oLog->Set('userinfo', '');
|
||||
$oLog->Set('issue', $e->GetIssue());
|
||||
$sIssue = ($e instanceof CoreException) ? $e->GetIssue() : 'PHP Exception';
|
||||
$oLog->Set('issue', $sIssue);
|
||||
$oLog->Set('impact', 'Page could not be displayed');
|
||||
$oLog->Set('callstack', $e->getFullStackTraceAsString());
|
||||
$oLog->Set('data', $e->getContextData());
|
||||
$oLog->Set('callstack', $sErrorStackTrace);
|
||||
$aData = ($e instanceof CoreException) ? $e->getContextData() : [];
|
||||
$oLog->Set('data', $aData);
|
||||
$oLog->DBInsertNoReload();
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
catch (Exception $e) {
|
||||
IssueLog::Error("Failed to log issue into the DB");
|
||||
}
|
||||
}
|
||||
|
||||
IssueLog::Error('UI.php operation='.$operation.', error='.$e->getMessage()."\n".$e->getFullStackTraceAsString());
|
||||
}
|
||||
|
||||
// For debugging only
|
||||
//throw $e;
|
||||
$sOperationToLog = $operation ?? 'N/A';
|
||||
IssueLog::Debug('UI.php operation='.$sOperationToLog.', error='.$e->getMessage()."\n".$sErrorStackTrace, 'console');
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
require_once(APPROOT.'/setup/setuppage.class.inc.php');
|
||||
$oP = new ErrorPage(Dict::S('UI:PageTitle:FatalError'));
|
||||
$oP->add("<h1>".Dict::S('UI:FatalErrorMessage')."</h1>\n");
|
||||
$oP->error(Dict::Format('UI:Error_Details', $e->getMessage()));
|
||||
$oP->output();
|
||||
|
||||
if (MetaModel::IsLogEnabledIssue())
|
||||
{
|
||||
if (MetaModel::IsValidClass('EventIssue'))
|
||||
{
|
||||
try
|
||||
{
|
||||
$oLog = new EventIssue();
|
||||
|
||||
$oLog->Set('message', $e->getMessage());
|
||||
$oLog->Set('userinfo', '');
|
||||
$oLog->Set('issue', 'PHP Exception');
|
||||
$oLog->Set('impact', 'Page could not be displayed');
|
||||
$oLog->Set('callstack', $e->getTrace());
|
||||
$oLog->Set('data', array());
|
||||
$oLog->DBInsertNoReload();
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
IssueLog::Error("Failed to log issue into the DB");
|
||||
}
|
||||
}
|
||||
|
||||
IssueLog::Error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
class UI
|
||||
{
|
||||
|
||||
@@ -10,6 +10,9 @@ use Combodo\iTop\Application\UI\Base\Layout\UIContentBlockUIBlockFactory;
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @since 2.7.1 N°2641 class creation
|
||||
*/
|
||||
class ErrorPage extends NiceWebPage
|
||||
{
|
||||
public function __construct($sTitle)
|
||||
|
||||
Reference in New Issue
Block a user