Skip Next call using Exception Handling
Tue Nov 12 2024 08:24:29 GMT+0000 (Coordinated Universal Time)
Saved by
@Manjunath
[ExtensionOf(classStr(SrsPrintDestinationTokensNone))]
final class SrsPrintDestinationTokensNone_DC_Extension
{ ///
expandEmailToken(SrsPrintDestinationToken _token, SRSPrintDestinationSettings _settings)
{
boolean mustSkipNext = true;
str tokenNotFoundMsg;
// Skip the next by using the following trick with the try-catch block.
//The base expandEmailToken() method generates a warning message that causes
// problems if infolog contains some old warnings or error messages.
try
{
if (mustSkipNext)
{
// When an exception is thrown inside a ttsBegin-ttsCommit transaction block, no catch statement inside that transaction block can process the exception,
// unless it is a UpdateConflict or a DuplicateKeyException. We always want to be sure that the catch block is executed,
//so we use the UpdateConflict exception.
throw Exception::UpdateConflict;
}
tokenNotFoundMsg = next expandEmailToken(_token, _settings);
}
catch (Exception::UpdateConflict)
{
// Don't expand the token, and don't show the error. Let Docentric report DSP class to deal with this.
tokenNotFoundMsg = DocConstantPlaceholder::PlaceholderStartSymbol + _token + DocConstantPlaceholder::PlaceholderEndSymbol;
}
return tokenNotFoundMsg;
}
}
content_copyCOPY
https://ax.docentric.com/how-to-skip-next-in-coc-of-a-method-in-xpp/
Comments