Skip to content

Commit

Permalink
🚸 Add error to departures (#3038)
Browse files Browse the repository at this point in the history
  • Loading branch information
HerrLevin authored Dec 12, 2024
1 parent 7461f5a commit 883e5f3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 8 additions & 4 deletions app/Http/Controllers/HafasController.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ public static function fetchDepartures(
TravelType $type = null,
bool $skipTimeShift = false
) {
$client = self::getHttpClient();
$time = $skipTimeShift ? $when : (clone $when)->shiftTimezone("Europe/Berlin");
$query = [
$client = self::getHttpClient();
$time = $skipTimeShift ? $when : (clone $when)->shiftTimezone("Europe/Berlin");
$query = [
'when' => $time->toIso8601String(),
'duration' => $duration,
HTT::NATIONAL_EXPRESS->value => self::checkTravelType($type, TravelType::EXPRESS),
Expand All @@ -187,7 +187,11 @@ public static function fetchDepartures(
HTT::TRAM->value => self::checkTravelType($type, TravelType::TRAM),
HTT::TAXI->value => self::checkTravelType($type, TravelType::TAXI),
];
$response = $client->get('/stops/' . $station->ibnr . '/departures', $query);
try {
$response = $client->get('/stops/' . $station->ibnr . '/departures', $query);
} catch (Exception $exception) {
throw new HafasException($exception->getMessage());
}

if (!$response->ok()) {
throw new HafasException(__('messages.exception.generalHafas'));
Expand Down
4 changes: 4 additions & 0 deletions resources/vue/components/Stationboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ export default {
this.firstFetchTime = DateTime.fromISO(this.meta?.times?.now);
});
} else {
if (response.status === 502) {
window.notyf.error(trans("messages.exception.hafas.502"))
}
}
});
},
Expand Down

0 comments on commit 883e5f3

Please sign in to comment.