From 7acd7a42f7663aa79d18e24bdb9fe19bf15f8fae Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 21 Nov 2015 19:02:49 +0100 Subject: Log details about sent mails in a file --- src/Main.hs | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'src/Main.hs') diff --git a/src/Main.hs b/src/Main.hs index d72bd95..0aa2910 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -6,6 +6,7 @@ module Main import System.IO (stderr) +import Data.Text (Text) import qualified Data.Text as T import qualified Data.Text.IO as T @@ -28,24 +29,32 @@ main = do eitherConfig <- getConfig configPath case (eitherBirthdates, eitherConfig) of (Left err, _) -> - T.hPutStr stderr $ - T.concat - [ "Error while parsing file " - , T.pack birthdatePath - , ":\n" - , err - ] + birthdateError err (_, Left err) -> - T.hPutStr stderr $ - T.concat - [ "Error while parsing config file " - , T.pack birthdatePath - , ":\n" - , err - ] + configError err (Right birthdates, Right config) -> sendNotificationForBirthdayToday birthdates config +birthdateError :: Text -> IO () +birthdateError err = + T.hPutStr stderr $ + T.concat + [ "Error while parsing file " + , T.pack birthdatePath + , ":\n" + , err + ] + +configError :: Text -> IO () +configError err = + T.hPutStr stderr $ + T.concat + [ "Error while parsing config file " + , T.pack configPath + , ":\n" + , err + ] + sendNotificationForBirthdayToday :: [Birthdate] -> Config -> IO () sendNotificationForBirthdayToday birthdates config = do currentDate <- getCurrentDate -- cgit v1.2.3