mirror of
https://git.nerfingen.de/nerf/choirMail.git
synced 2025-06-08 09:41:00 +00:00
added error handling to the web request (and changed from req to wreq)
This commit is contained in:
parent
6f50add62a
commit
a460fd561f
5 changed files with 44 additions and 34 deletions
|
@ -3,12 +3,11 @@ module TableParser(MailRecord(..), parseBString, parseTable) where
|
|||
|
||||
import qualified Text.Parsec as P
|
||||
-- import qualified Text.Parsec.Char as P
|
||||
import qualified Text.Parsec.Text as P
|
||||
import qualified Text.Parsec.Text.Lazy as P
|
||||
import qualified Data.Text.Lazy as LT
|
||||
import qualified Data.Text as ST
|
||||
import qualified Data.Text.Encoding as ST
|
||||
import qualified Data.Text.Lazy.Encoding as LT
|
||||
import qualified Data.Time.Calendar as D
|
||||
import qualified Data.ByteString as B
|
||||
import qualified Data.ByteString.Lazy as B
|
||||
import Control.Monad(void)
|
||||
|
||||
|
||||
|
@ -70,7 +69,7 @@ parseTable = do
|
|||
P.eof
|
||||
return x
|
||||
|
||||
textToMailRecord :: ST.Text -> Either String [MailRecord]
|
||||
textToMailRecord :: LT.Text -> Either String [MailRecord]
|
||||
textToMailRecord t = case P.parse parseTable "" t of
|
||||
Left x -> Left $ show x
|
||||
Right x -> Right x
|
||||
|
@ -81,7 +80,7 @@ parseBString t = do
|
|||
text <- toText t
|
||||
textToMailRecord text
|
||||
|
||||
toText :: B.ByteString -> Either String ST.Text
|
||||
toText t = case ST.decodeUtf8' t of
|
||||
toText :: B.ByteString -> Either String LT.Text
|
||||
toText t = case LT.decodeUtf8' t of
|
||||
Left x -> Left $ show x
|
||||
Right x -> Right x
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue