Tauhid Rehman
01/19/2021, 9:12 AMif (error.contains (specialCase)) {
throw specialCaseException
}
<http://LOGGER.info|LOGGER.info>("logspecialCaseInfoAsInfo")
Tobias Berger
01/19/2021, 9:56 AMthrow
statement.Matteo Mirk
01/19/2021, 10:24 AMTobias Berger
01/19/2021, 11:04 AMTauhid Rehman
01/19/2021, 7:06 PMif (error.contains (specialCase)) {
<http://LOGGER.info|LOGGER.info>("logspecialCaseInfoAsInfo")
throw specialCaseException
}
OR
if (error.contains (specialCase)) {
throw specialCaseException.also {
<http://LOGGER.info|LOGGER.info>("logspecialCaseInfoAsInfo")
}
Tobias Berger
01/20/2021, 8:28 AMit
inside)
Anyways, this doesn't avoid the anti-pattern at all. You are logging something and then throwing an exception, which will usually also be logged somewhere else. So you should ask yourself why do you need the additional log? If there is information relevant to the error, why is it not included in the exception you're throwing?Matteo Mirk
01/20/2021, 9:19 AM