Skip to content

Commit 519cbb7

Browse files
Throw exceptions from buildNetwork
Remove try/catch block that did not allow exceptions to bubble up to the user during network building and saving.
1 parent 9ba72c3 commit 519cbb7

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/main/java/com/conveyal/r5/transit/TransportNetworkCache.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ private TransportNetworkConfig loadNetworkConfig (String networkId) {
197197
* If we did not find a cached network, build one from the input files. Should throw an exception rather than
198198
* returning null if for any reason it can't finish building one.
199199
*/
200-
private @Nonnull TransportNetwork buildNetwork (String networkId) {
200+
private @Nonnull TransportNetwork buildNetwork(String networkId) throws IOException {
201201
TransportNetwork network;
202202
TransportNetworkConfig networkConfig = loadNetworkConfig(networkId);
203203
if (networkConfig == null) {
@@ -225,14 +225,10 @@ private TransportNetworkConfig loadNetworkConfig (String networkId) {
225225
network.rebuildLinkedGridPointSet(buildGridsForModes);
226226

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

0 commit comments

Comments
 (0)