Last active
December 17, 2018 21:23
-
-
Save mchmielarz/3eb23ad94a747029b721d4e4a7043e4d to your computer and use it in GitHub Desktop.
Read geo coordinates from a file with recovery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Try.of( | |
() -> geoCoordinatesReader.fromCsvFile("./src/main/resources/cities.csv") | |
) | |
.onSuccess(coords -> log.info("Coordinates read: {}", coords)) | |
.onFailure(exc -> log.error("Cannot read coordinates from a file", exc)) | |
.recover(FileNotFoundException.class, (exc) -> provideBackupCoordinates()) | |
.getOrElse(List.empty()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment