Skip to content

Commit

Permalink
Add error to departures
Browse files Browse the repository at this point in the history
  • Loading branch information
HerrLevin committed Dec 12, 2024
1 parent 12c7062 commit a156b4c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/DataProviders/Hafas.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ private function fetchDepartures(
TravelType $type = null,
bool $skipTimeShift = false
) {
$time = $skipTimeShift ? $when : (clone $when)->shiftTimezone("Europe/Berlin");
$query = [
$time = $skipTimeShift ? $when : (clone $when)->shiftTimezone("Europe/Berlin");
$query = [
'when' => $time->toIso8601String(),
'duration' => $duration,
HTT::NATIONAL_EXPRESS->value => FptfHelper::checkTravelType($type, TravelType::EXPRESS),
Expand All @@ -143,7 +143,11 @@ private function fetchDepartures(
HTT::TRAM->value => FptfHelper::checkTravelType($type, TravelType::TRAM),
HTT::TAXI->value => FptfHelper::checkTravelType($type, TravelType::TAXI),
];
$response = $this->client()->get('/stops/' . $station->ibnr . '/departures', $query);
try {
$response = $this->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

0 comments on commit a156b4c

Please sign in to comment.