From: Michael Orlitzky Date: Mon, 20 Aug 2012 19:44:25 +0000 (-0400) Subject: Print an error before usage if we can't parse the page. X-Git-Tag: v0.0.1~6 X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dead%2Flwn-epub.git;a=commitdiff_plain;h=291c39f59e958a012dd6e4ddec9b0276a4045b45 Print an error before usage if we can't parse the page. --- diff --git a/src/Main.hs b/src/Main.hs index 3ce1eef..1f6d7c5 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -7,8 +7,11 @@ import System.Directory (doesFileExist) import System.IO ( Handle, IOMode (WriteMode), + hPutStrLn, openBinaryFile, - stdout) + stderr, + stdout + ) import CommandLine (show_help) import Configuration (Cfg(..), get_cfg) @@ -40,12 +43,14 @@ main = do 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 + hPutStrLn stderr "ERROR: could not parse an LWN page from the given URL." _ <- show_help return ()