英文:
complaining about logging and rethrowing the exception in sonar
问题
我在程序中有以下一段代码,并且在将其与Maven集成后,我正在运行SonarQube进行代码质量检查。
然而,Sonar提示我应该记录(log)这个异常或重新抛出(rethrow)它。
我在这里漏掉了什么?难道我没有已经记录这个异常吗?
public AccountResponse getAccountStatus(AccessIDSearchResponse accessIDResponse) {
accountResponse = null;
try {
AccountRequest request = new AccountRequest();
} catch (ServiceException serviceException) {
log.error("getAccountStatus-GotServiceException =" + ExceptionUtils.getStackTrace(serviceException));
throw serviceException;
} catch (Exception e) {
throw new ServiceException(ErrorMessages.EPO_SYSTEM_ERROR, e.getMessage());
}
return accountResponse;
}
[![enter image description here][1]][1]
<details>
<summary>英文:</summary>
I have the following piece of code in my program and I am running SonarQube for code quality check on it after integrating it with Maven.
However, Sonar is complaining that I should Either log or rethrow this exception.
What am I missing here? Am I not already logging the exception?
public AccountResponse getAccountStatus(AccessIDSearchResponse accessIDResponse) {
accountResponse = null;
try {
AccountRequest request = new AccountRequest();
} catch (ServiceException serviceException) {
log.error("getAccountStatus-GotServiceException =" + ExceptionUtils.getStackTrace(serviceException));
throw serviceException;
} catch (Exception e) {
throw new ServiceException(ErrorMessages.EPO_SYSTEM_ERROR, e.getMessage());
}
return accountResponse;
}
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/t0sgW.png
</details>
专注分享java语言的经验与见解,让所有开发者获益!
评论