From 6701e40f9e1315e4fe87474a6016468c3bf9b151 Mon Sep 17 00:00:00 2001 From: Simon Huber Date: Thu, 9 Apr 2015 00:42:29 +0200 Subject: [PATCH] don't crash the main loop if error in eval --- Main.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Main.hs b/Main.hs index d873449..71fdab4 100644 --- a/Main.hs +++ b/Main.hs @@ -2,6 +2,7 @@ module Main where import Control.Monad.Trans.Reader import Control.Monad.Error +import Control.Exception (try) import Data.List import System.Directory import System.FilePath @@ -126,7 +127,10 @@ loop flags f names tenv@(TC.TEnv _ rho _) = do loop flags f names tenv Right _ -> do let e = E.eval rho body - outputStrLn ("EVAL: " ++ show e) + -- Let's not crash if the evaluation raises an error: + liftIO $ catch (putStrLn ("EVAL: " ++ show e)) + (\e -> putStrLn ("Exception: " ++ + show (e :: SomeException))) loop flags f names tenv -- (not ok,loaded,already loaded defs) -> to load -> -- 2.34.1