File tree Expand file tree Collapse file tree 3 files changed +24
-10
lines changed
commonMain/kotlin/com/jdamcd/arrivals/gtfs
jvmTest/kotlin/com/jdamcd/arrivals/gtfs Expand file tree Collapse file tree 3 files changed +24
-10
lines changed Original file line number Diff line number Diff line change 468468 "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
469469 CODE_SIGN_STYLE = Manual;
470470 COMBINE_HIDPI_IMAGES = YES;
471- CURRENT_PROJECT_VERSION = 4 ;
471+ CURRENT_PROJECT_VERSION = 5 ;
472472 DEAD_CODE_STRIPPING = YES;
473473 DEVELOPMENT_ASSET_PATHS = "\"Arrivals/Preview Content\"";
474474 DEVELOPMENT_TEAM = "";
486486 "$(inherited)",
487487 "@executable_path/../Frameworks",
488488 );
489- MARKETING_VERSION = 0.4 ;
489+ MARKETING_VERSION = 0.5 ;
490490 OTHER_LDFLAGS = (
491491 "$(inherited)",
492492 "-framework",
511511 "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
512512 CODE_SIGN_STYLE = Manual;
513513 COMBINE_HIDPI_IMAGES = YES;
514- CURRENT_PROJECT_VERSION = 4 ;
514+ CURRENT_PROJECT_VERSION = 5 ;
515515 DEAD_CODE_STRIPPING = YES;
516516 DEVELOPMENT_ASSET_PATHS = "\"Arrivals/Preview Content\"";
517517 DEVELOPMENT_TEAM = "";
530530 "$(inherited)",
531531 "@executable_path/../Frameworks",
532532 );
533- MARKETING_VERSION = 0.4 ;
533+ MARKETING_VERSION = 0.5 ;
534534 OTHER_LDFLAGS = (
535535 "$(inherited)",
536536 "-framework",
Original file line number Diff line number Diff line change @@ -31,16 +31,20 @@ internal class GtfsArrivals(
3131 throw NoDataException (" No arrivals found" )
3232 }
3333 } catch (e: Exception ) {
34- throw NoDataException (" No connection " )
34+ throw NoDataException (" Failed to connect " )
3535 }
3636 }
3737
3838 private suspend fun updateStops () {
39- if (! hasFreshStops()) {
40- stops = GtfsStops (api.downloadStops(settings.gtfsSchedule))
41- settings.gtfsStopsUpdated = clock.now().epochSeconds
42- } else if (! ::stops.isInitialized) {
43- stops = GtfsStops (api.readStops())
39+ try {
40+ if (! hasFreshStops()) {
41+ stops = GtfsStops (api.downloadStops(settings.gtfsSchedule))
42+ settings.gtfsStopsUpdated = clock.now().epochSeconds
43+ } else if (! ::stops.isInitialized) {
44+ stops = GtfsStops (api.readStops())
45+ }
46+ } catch (e: Exception ) {
47+ throw NoDataException (" Failed to load stops" )
4448 }
4549 }
4650
Original file line number Diff line number Diff line change @@ -98,4 +98,14 @@ class GtfsArrivalsTest {
9898 coVerify { api.downloadStops(" schedule_url" ) }
9999 latest.arrivals shouldHaveSize 3
100100 }
101+
102+ @Test
103+ fun `throws NoDataException if stops fail to load` () = runBlocking<Unit > {
104+ every { clock.now() } returns Instant .fromEpochSeconds(fetchTime)
105+ coEvery { api.downloadStops(" schedule_url" ) } throws Exception ()
106+
107+ assertFailsWith<NoDataException > {
108+ arrivals.latest()
109+ }
110+ }
101111}
You can’t perform that action at this time.
0 commit comments