aboutsummaryrefslogtreecommitdiff
path: root/src/Main.hs
diff options
context:
space:
mode:
authorJoris2015-11-21 19:02:49 +0100
committerJoris2015-11-21 19:02:54 +0100
commit7acd7a42f7663aa79d18e24bdb9fe19bf15f8fae (patch)
tree000d1d157ff33917358ded8100980d018e437f7f /src/Main.hs
parent6850159bf998a209ad7b6d7103d113a54659937e (diff)
downloadevents-7acd7a42f7663aa79d18e24bdb9fe19bf15f8fae.tar.gz
events-7acd7a42f7663aa79d18e24bdb9fe19bf15f8fae.tar.bz2
events-7acd7a42f7663aa79d18e24bdb9fe19bf15f8fae.zip
Log details about sent mails in a file
Diffstat (limited to 'src/Main.hs')
-rw-r--r--src/Main.hs37
1 files changed, 23 insertions, 14 deletions
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