improved checking if city exists and formatDate function

This commit is contained in:
K4RP4T 2024-05-26 12:54:34 +02:00
parent 8038361c76
commit bcc8c40243

View File

@ -22,7 +22,7 @@ main = do
let cityRequest = apiRequestCity apiKey city
cityResponse <- httpLBS cityRequest
if getResponseBody cityResponse == "[]"
if getResponseBody cityResponse == "[]" || getResponseStatusCode cityResponse /= 200
then error "City not found!"
else do
currentDate <- getCurrentDate
@ -101,4 +101,4 @@ getCurrentDate = do
formatDate :: Day -> String
formatDate date = formatTime defaultTimeLocale "%Y-%m-%d" date
formatDate = formatTime defaultTimeLocale "%Y-%m-%d"