需要Kotlin的快速帮助。下面是伪代码:当出现"specialCase"错误时,抛出异常并将此异常记录为"Info"。这是if语句。这看起来是个好方法吗?
if (error.contains (specialCase))
{
throw specialCaseDoesNotExistException
}
LOGGER.info("WriteSpecialCaseasInfoandNOTError")
在之前记录或者您可以使用also
(引用)将其组合成单个语句:
if (error.contains (specialCase)) {
LOGGER.info("WriteSpecialCaseasInfoandNOTError")
throw specialCaseDoesNotExistException
}
if (error.contains (specialCase)) {
throw specialCaseDoesNotExistException.also {
LOGGER.info("WriteSpecialCaseasInfoandNOTError")
}
}