Error handling 我应该在日志或内部异常中打印错误消息,还是两者都打印?

Error handling 我应该在日志或内部异常中打印错误消息,还是两者都打印?,error-handling,error-logging,Error Handling,Error Logging,我在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") 我应该写两次留言吗?或者我应该只记录错误并抛出空异常吗?这取决于用例到用例。

我在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")

我应该写两次留言吗?或者我应该只记录错误并抛出空异常吗?

这取决于用例到用例。 如果日志语句在dev范围内,则无需向源/调用方抛出异常。您可以记录异常并使其静音,然后将有用的消息/代码返回给源代码/调用者