From ff722c754db544df602486e09fce000040e97d07 Mon Sep 17 00:00:00 2001 From: Zoe Moore Date: Thu, 30 Jun 2022 18:00:53 -0700 Subject: [PATCH] Add proper error checking --- bt.nim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bt.nim b/bt.nim index d7a720d..c47f6f3 100644 --- a/bt.nim +++ b/bt.nim @@ -52,6 +52,10 @@ proc parseStation(station: string): string = else: station proc formatDepartures(etd: JSONNode): string = + if not etd["root"].hasKey("station"): + echo "No departures for this station" + return + let name = etd["root"]["station"][0]["name"].getStr let lines = etd["root"]["station"][0]["etd"]