diff options
author | Camil Staps | 2016-01-28 10:19:22 +0100 |
---|---|---|
committer | Camil Staps | 2016-01-28 10:19:22 +0100 |
commit | bca2621a04ae4022a3ab625948877cba006d41fe (patch) | |
tree | 0bde902c28b359634474652634e862945758bd39 | |
parent | Removed duplicate code; improved Makefile (diff) |
Improved error handling
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | iclean.icl | 10 |
2 files changed, 10 insertions, 2 deletions
@@ -1,3 +1,5 @@ Clean System Files *.o iclean +.iclean_history + @@ -42,9 +42,9 @@ Start :: *World -> *World Start w # w = setReadLineName "iClean" w # w = usingHistory w -# (_, w) = readHistory readline_history w +# w = checkedWorldFunc readHistory "Couldn't read history file\n" readline_history w # w = loop w -# (i, w) = writeHistory readline_history w +# w = checkedWorldFunc writeHistory "Couldn't write history file\n" readline_history w = w where loop :: !*World -> *World @@ -60,6 +60,12 @@ where # w = run (temp_path +++ temp_module) w = loop w +checkedWorldFunc :: (a *World -> (Bool, *World)) !String !a !*World -> *World +checkedWorldFunc f err s w +# (ok, w) = f s w +| not ok = print err w +| otherwise = w + print :: String *World -> *World print s w # (io,w) = stdio w |