我在Scala中有以下代码:
logger.error("Repository does not exists or does not contains 'definitions' directory")
throw new FileNotFoundException("Repository does not exists or does not contains 'definitions' directory")
我应该写两次消息吗?还是我应该只记录错误并抛出空异常?
答案 0 :(得分:1)
取决于用例,要视用例而定。 如果您的日志语句在dev-scope内,则无需向源/调用方抛出异常。您可以记录异常并将其静音,然后将有用的消息/代码返回给源/调用者。