Skip to content

Commit

Permalink
fix: convert logging to exception (#194)
Browse files Browse the repository at this point in the history
* fix: convert logging to exception

* fix: style
  • Loading branch information
jeremylong authored Jul 16, 2024
1 parent bb1bdb4 commit f471d7f
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -392,11 +392,14 @@ private Collection<DefCveItem> _next(int retryCount) {
LOG.debug("Response: {}", new String(response.getBodyBytes(), StandardCharsets.UTF_8));
if (msg != null) {
if (msg.contains("Invalid apiKey")) {
LOG.error("Invalid API Key: key length {}", this.apiKey.length());
if (this.apiKey.length() > 30) {
LOG.error("Invalid API Key: '{}-*****-{}", this.apiKey.substring(0, 5),
String masked = String.format("Invalid API Key: %s-*****-%s",
this.apiKey.substring(0, 5),
this.apiKey.substring(this.apiKey.length() - 5, this.apiKey.length()));
throw new NvdApiException(masked);
}
String masked = String.format("Invalid API Key: %s-*****", this.apiKey.substring(0, 5));
throw new NvdApiException(masked);
}
throw new NvdApiException("NVD Returned Status Code: " + lastStatusCode + " - " + msg);
}
Expand Down

0 comments on commit f471d7f

Please sign in to comment.