Skip to content

Commit

Permalink
Throw exceptions from buildNetwork
Browse files Browse the repository at this point in the history
Remove try/catch block that did not allow exceptions to bubble up to the user during network building and saving.
  • Loading branch information
trevorgerhardt committed Nov 6, 2024
1 parent 9ba72c3 commit 519cbb7
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/main/java/com/conveyal/r5/transit/TransportNetworkCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ private TransportNetworkConfig loadNetworkConfig (String networkId) {
* If we did not find a cached network, build one from the input files. Should throw an exception rather than
* returning null if for any reason it can't finish building one.
*/
private @Nonnull TransportNetwork buildNetwork (String networkId) {
private @Nonnull TransportNetwork buildNetwork(String networkId) throws IOException {
TransportNetwork network;
TransportNetworkConfig networkConfig = loadNetworkConfig(networkId);
if (networkConfig == null) {
Expand Down Expand Up @@ -225,14 +225,10 @@ private TransportNetworkConfig loadNetworkConfig (String networkId) {
network.rebuildLinkedGridPointSet(buildGridsForModes);

// Cache the serialized network on the local filesystem and mirror it to any remote storage.
try {
File cacheLocation = FileUtils.createScratchFile();
KryoNetworkSerializer.write(network, cacheLocation);
fileStorage.moveIntoStorage(getR5NetworkFileStorageKey(networkId), cacheLocation);
} catch (Exception e) {
// Tolerate exceptions here as we do have a network to return, we just failed to cache it.
LOG.error("Error saving cached network, returning the object anyway.", e);
}
File cacheLocation = FileUtils.createScratchFile();
KryoNetworkSerializer.write(network, cacheLocation);
fileStorage.moveIntoStorage(getR5NetworkFileStorageKey(networkId), cacheLocation);

return network;
}

Expand Down

0 comments on commit 519cbb7

Please sign in to comment.