summaryrefslogtreecommitdiffhomepage
path: root/Main.hs
diff options
context:
space:
mode:
authorAndrea Rossato <andrea.rossato@ing.unitn.it>2007-07-24 14:01:06 +0200
committerAndrea Rossato <andrea.rossato@ing.unitn.it>2007-07-24 14:01:06 +0200
commit60d538f76659f343b5fcdbb0ecbec6e157bdba91 (patch)
tree47c3b35c92170024d6efbaf81e3a348eb63c85e5 /Main.hs
parentbcb7793d5444be36bcb999409771d4493ec157a9 (diff)
downloadxmobar-60d538f76659f343b5fcdbb0ecbec6e157bdba91.tar.gz
xmobar-60d538f76659f343b5fcdbb0ecbec6e157bdba91.tar.bz2
better error handling in Main.hs
darcs-hash:20070724120106-d6583-0a4a02d25dddcf0c005a295db06e4a009851292d.gz
Diffstat (limited to 'Main.hs')
-rw-r--r--Main.hs7
1 files changed, 4 insertions, 3 deletions
diff --git a/Main.hs b/Main.hs
index 8ade001..8cf0403 100644
--- a/Main.hs
+++ b/Main.hs
@@ -51,10 +51,11 @@ main =
-- | Reads the configuration files or quits with an error
readConfig :: FilePath -> IO Config
readConfig f =
- do s <- readFile f
+ do file <- fileExist f
+ s <- if file then readFile f else error $ f ++ ": file not found!\n" ++ usage
case reads s of
[(config,_)] -> return config
- [] -> error ("Corrupt config file: " ++ f)
+ [] -> error $ f ++ ": configuration file contains errors!\n" ++ usage
_ -> error ("Some problem occured. Aborting...")
-- | Read default configuration file or load the default config
@@ -108,7 +109,7 @@ getOpts argv =
usage :: String
usage = (usageInfo header options) ++ footer
where header = "Usage: xmobar [OPTION...] [FILE]\nOptions:"
- footer = "Mail bug reports and suggestions to " ++ mail
+ footer = "\nMail bug reports and suggestions to " ++ mail
version :: String
version = "Xmobar 0.7 (C) 2007 Andrea Rossato " ++ mail ++ license