From ab7c39b7077eb37f1486bfa849d51def361928bf Mon Sep 17 00:00:00 2001 From: Dennis Frieberg Date: Sat, 7 Jun 2025 03:36:39 +0200 Subject: [PATCH] if we send an error mail, we also print the error to stderr --- README.md | 2 +- app/Main.hs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 038d91f..944513c 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ this depends on your local cabal cache. - [ ] Add the nix modules to the flake - [ ] Better Error handling - [x] Find out which exceptions the SMTP module throws - - [ ] also log to stderr if we send an error E-Mail + - [x] also log to stderr if we send an error E-Mail - [ ] move from MonadFail to MonadError from Control.Monad.Except - [ ] Split config into secrets and non secret config - [ ] make the pad url configurable diff --git a/app/Main.hs b/app/Main.hs index cc6c243..65ef276 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -25,7 +25,9 @@ reportErrorLocal :: MonadIO m => String -> m () reportErrorLocal = liftIO . hPutStr stderr reportErrorMail :: MonadIO m => Config -> String -> m () -reportErrorMail config error' = send (mailDomain config) (mailUsername config) (mailPassword config) (mailErrorTo config) (mailFrom config) "choirMail Error" (LT.pack error') +reportErrorMail config error' = do + reportErrorLocal error' + send (mailDomain config) (mailUsername config) (mailPassword config) (mailErrorTo config) (mailFrom config) "choirMail Error" (LT.pack error') findChoirDay :: Day -> [MailRecord] -> Either String MailRecord findChoirDay today table = maybe