]> gitweb.michael.orlitzky.com - dead/lwn-epub.git/blobdiff - src/Main.hs
Print an error before usage if we can't parse the page.
[dead/lwn-epub.git] / src / Main.hs
index a1230d60e836c08e849f9c40e78b34e6c4925151..1f6d7c5f436a583d5143b05c1cf55aaf4126995e 100644 (file)
@@ -2,12 +2,16 @@
 module Main
 where
 
 module Main
 where
 
+import Control.Concurrent.ParallelIO (stopGlobalPool)
 import System.Directory (doesFileExist)
 import System.IO (
   Handle,
   IOMode (WriteMode),
 import System.Directory (doesFileExist)
 import System.IO (
   Handle,
   IOMode (WriteMode),
+  hPutStrLn,
   openBinaryFile,
   openBinaryFile,
-  stdout)
+  stderr,
+  stdout
+  )
 
 import CommandLine (show_help)
 import Configuration (Cfg(..), get_cfg)
 
 import CommandLine (show_help)
 import Configuration (Cfg(..), get_cfg)
@@ -39,11 +43,16 @@ main = do
   cfg  <- case aif of
            False -> get_login_cookie cfg'
            True  -> return cfg'
   cfg  <- case aif of
            False -> get_login_cookie cfg'
            True  -> return cfg'
+
   page <- page_from_url cfg (article cfg)
   case page of
     Just p -> do
       output_handle <- get_output_handle (output cfg)
       epublish p output_handle
     Nothing -> do
   page <- page_from_url cfg (article cfg)
   case page of
     Just p -> do
       output_handle <- get_output_handle (output cfg)
       epublish p output_handle
     Nothing -> do
+      hPutStrLn stderr "ERROR: could not parse an LWN page from the given URL."
       _ <- show_help
       return ()
       _ <- show_help
       return ()
+
+  -- Necessary, for some reason.
+  stopGlobalPool