From bca2621a04ae4022a3ab625948877cba006d41fe Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Thu, 28 Jan 2016 10:19:22 +0100 Subject: Improved error handling --- .gitignore | 2 ++ iclean.icl | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 2fdc4e0..51a17d0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ Clean System Files *.o iclean +.iclean_history + diff --git a/iclean.icl b/iclean.icl index 6f7ff04..9f51c05 100644 --- a/iclean.icl +++ b/iclean.icl @@ -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 -- cgit v1.2.3