improved checking if city exists and formatDate function
This commit is contained in:
parent
8038361c76
commit
bcc8c40243
@ -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"
|
Loading…
Reference in New Issue
Block a user