Add proper error checking
This commit is contained in:
4
bt.nim
4
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"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user