Skip to content

Commit

Permalink
Slightly improved error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg committed Jan 27, 2014
1 parent fb0d299 commit e11af23
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
18 changes: 12 additions & 6 deletions Application.hs
Expand Up @@ -66,8 +66,14 @@ getApplication conf = do
s <- staticSite
let assets = Static $ defaultFileServerSettings "content/static"

mblog <- loadBlog
iblog <- newIORef $ fromMaybe (error "Invalid posts.yaml") mblog
eblog <- loadBlog
blog <-
case eblog of
Left e -> do
print e
return $ error $ "Invalid posts.yaml: " ++ show e
Right b -> return b
iblog <- newIORef blog
booksub12 <- mkBookSub "Yesod Web Framework Book- Version 1.2" "" $ F.decodeString dirCurrent
booksub11 <- mkBookSub "Yesod Web Framework Book- Version 1.1" "Note: You are looking at version 1.1 of the book, which is one version behind" $ F.decodeString dir11
iauthors <- loadAuthors >>= newIORef
Expand Down Expand Up @@ -125,10 +131,10 @@ postReloadR = do
let run x y = runProcess x y (Just dir) Nothing Nothing Nothing Nothing >>= waitForProcess >> return ()
run "git" ["fetch"]
run "git" ["checkout", "origin/" ++ branch]
mblog <- loadBlog
case mblog of
Nothing -> return ()
Just blog -> writeIORef (ywBlog yw) blog
eblog <- loadBlog
case eblog of
Left e -> print e
Right blog -> writeIORef (ywBlog yw) blog
bsReload $ getBook12 yw
bsReload $ getBook11 yw
loadAuthors >>= writeIORef (ywAuthors yw)
Expand Down
4 changes: 2 additions & 2 deletions Import.hs
Expand Up @@ -69,8 +69,8 @@ prettyDay = formatTime defaultTimeLocale "%B %e, %Y"
loadBook :: F.FilePath -> IO Book.Book
loadBook root = Book.loadBook $ root F.</> "yesod-web-framework-book.asciidoc"

loadBlog :: IO (Maybe Blog)
loadBlog = Data.Yaml.decodeFile $ F.encodeString $ blogRoot F.</> "posts.yaml"
loadBlog :: IO (Either Data.Yaml.ParseException Blog)
loadBlog = Data.Yaml.decodeFileEither $ F.encodeString $ blogRoot F.</> "posts.yaml"

loadAuthors :: IO (Map.Map Text Author)
loadAuthors = fromMaybe Map.empty <$> (Data.Yaml.decodeFile $ F.encodeString $ blogRoot F.</> "authors.yaml")
Expand Down
6 changes: 3 additions & 3 deletions yesodweb.cabal
Expand Up @@ -46,7 +46,7 @@ executable yesodweb
, yesod-form >= 1.2 && < 1.4
, yesod-newsfeed >= 1.2 && < 1.3
, bytestring >= 0.9 && < 0.11
, text >= 0.11 && < 0.12
, text >= 0.11
, template-haskell
, hamlet >= 1.1 && < 1.2
, shakespeare-css >= 1.0 && < 1.1
Expand All @@ -56,13 +56,13 @@ executable yesodweb
, monad-control >= 0.3 && < 0.4
, wai-extra >= 2.0 && < 2.1
, yaml >= 0.8 && < 0.9
, blaze-html >= 0.5 && < 0.7
, blaze-html >= 0.7 && < 0.8
, conduit >= 0.5.2.1 && < 1.1
, resourcet >= 0.3 && < 0.5
, xss-sanitize >= 0.3.1 && < 0.4
, system-filepath >= 0.4.4 && < 0.5
, system-fileio >= 0.3 && < 0.4
, attoparsec >= 0.10 && < 0.11
, attoparsec >= 0.10
, attoparsec-conduit >= 0.5 && < 1.1
, data-default
, xml-conduit >= 1.0 && < 1.2
Expand Down

0 comments on commit e11af23

Please sign in to comment.