From 519cbb70d8b0af81aa0877f07ca51f81833e8b3a Mon Sep 17 00:00:00 2001 From: Trevor Gerhardt Date: Thu, 24 Oct 2024 09:17:52 +0800 Subject: [PATCH] Throw exceptions from buildNetwork Remove try/catch block that did not allow exceptions to bubble up to the user during network building and saving. --- .../conveyal/r5/transit/TransportNetworkCache.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/conveyal/r5/transit/TransportNetworkCache.java b/src/main/java/com/conveyal/r5/transit/TransportNetworkCache.java index c67fe9d24..a9f5284ca 100644 --- a/src/main/java/com/conveyal/r5/transit/TransportNetworkCache.java +++ b/src/main/java/com/conveyal/r5/transit/TransportNetworkCache.java @@ -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) { @@ -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; }