Skip to content

Commit

Permalink
fix: improve error handling (#65)
Browse files Browse the repository at this point in the history
resolves #64
  • Loading branch information
jeremylong authored Aug 16, 2023
1 parent 32fb9b5 commit 4c6b8b2
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,14 @@ public Integer timedCall() throws Exception {
if (configGroup.cacheSettings.prefix != null) {
properties.set("prefix", configGroup.cacheSettings.prefix);
}
int status = processRequest(builder, properties);
properties.save();
return status;
try {
int status = processRequest(builder, properties);
properties.save();
return status;
} catch (CacheException ex) {
LOG.error(ex.getMessage());
}
return 1;
}
if (configGroup != null && configGroup.modifiedRange != null
&& configGroup.modifiedRange.lastModStartDate != null) {
Expand Down Expand Up @@ -248,7 +253,8 @@ private Integer processRequest(NvdCveClientBuilder builder, CacheProperties prop
lastModified = api.getLastUpdated();
}
} catch (Exception ex) {
LOG.error("\nERROR", ex);
LOG.debug("\nERROR", ex);
throw new CacheException("Unable to complete NVD cache update due to error: " + ex.getMessage());
}
if (lastModified != null) {
properties.set("lastModifiedDate", lastModified);
Expand All @@ -269,7 +275,7 @@ private Integer processRequest(NvdCveClientBuilder builder, CacheProperties prop
try {
objectMapper.writeValue(file, data);
} catch (IOException ex) {
throw new CacheException("Unable to read cached data: " + file, ex);
throw new CacheException("Unable to write cached data: " + file, ex);
}
}
return 0;
Expand Down

0 comments on commit 4c6b8b2

Please sign in to comment.