N°3270 Notify on expiration not sending notification (trigger exception)

add boilerplate function and use it to intercept/enrich trigger exception loops
This commit is contained in:
odain
2020-08-21 18:10:48 +02:00
parent 94b9a9bb75
commit 4e0eed6e13
8 changed files with 173 additions and 13 deletions

View File

@@ -2315,4 +2315,26 @@ class utils
{
return str_replace(' ', '', ucwords(strtr($sInput, '_-', ' ')));
}
/**
* @param \cmdbAbstractObject $oCmdbAbstract
* @param \Exception $oException
*
* @throws \Exception
* @since 2.7.2/ 2.8.0
*/
public static function EnrichRaisedException($oCmdbAbstract, $oException)
{
if (is_null($oCmdbAbstract) ||
! is_a($oCmdbAbstract, \cmdbAbstractObject::class))
{
throw $oException;
}
$sCmdbAbstractInfo = str_replace("\n", '', "" . $oCmdbAbstract);
$sMessage = $oException->getMessage() . " (" . $sCmdbAbstractInfo . ")";
$e = new CoreException($sMessage, null, '', $oException);
throw $e;
}
}