Skip to content

Commit

Permalink
fix: handling errors
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianflatner committed Oct 22, 2024
1 parent 86e0979 commit a6372b0
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions tavla/app/(admin)/components/TileSelector/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { getFormFeedbackForError } from 'app/(admin)/utils'
import {
QuayCoordinatesQuery,
StopPlaceCoordinatesQuery,
Expand Down Expand Up @@ -31,8 +30,7 @@ export function formDataToTile(data: FormData, organization?: TOrganization) {
}

export async function getWalkingDistance(from: TCoordinate, to: TCoordinate) {
if (!to) return getFormFeedbackForError()
if (!from) return undefined
if (!from || !to) return undefined
try {
const response = await fetchQuery(WalkDistanceQuery, {
from: {
Expand All @@ -46,7 +44,7 @@ export async function getWalkingDistance(from: TCoordinate, to: TCoordinate) {
})
return response.trip.tripPatterns[0]?.duration
} catch (error) {
return getFormFeedbackForError()
throw new Error('Failed to get walking distance')
}
}

Expand Down

0 comments on commit a6372b0

Please sign in to comment.