N°8772 - log for exception

This commit is contained in:
Eric Espie
2025-10-24 15:44:41 +02:00
parent 212309e938
commit 675db85131
2 changed files with 15 additions and 1 deletions

View File

@@ -715,6 +715,13 @@ abstract class LogAPI
static::$m_oMockMetaModelConfig = $oMetaModelConfig;
}
public static function Exception(string $sMessage, throwable $previous, string $sChannel = null, array $aContext = []): void
{
$aContext['Error Message'] = $previous->getMessage();
$aContext['Stack Trace'] = $previous->getTraceAsString();
static::Error($sMessage, $sChannel, $aContext);
}
public static function Error($sMessage, $sChannel = null, $aContext = array())
{
static::Log(self::LEVEL_ERROR, $sMessage, $sChannel, $aContext);

View File

@@ -6,7 +6,14 @@
namespace Combodo\iTop\Forms;
use IssueLog;
use Throwable;
class FormsException extends \Exception
{
public function __construct(string $message = '', int $code = 0, ?Throwable $previous = null, array $aContext = [])
{
IssueLog::Exception(get_class($this).' occurs', $this, null, $aContext);
parent::__construct($message, $code, $previous);
}
}