From: Simon Huber Date: Wed, 8 Apr 2015 22:42:29 +0000 (+0200) Subject: don't crash the main loop if error in eval X-Git-Url: https://git.ak3n.com/?a=commitdiff_plain;h=6701e40f9e1315e4fe87474a6016468c3bf9b151;p=cubicaltt.git don't crash the main loop if error in eval --- 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 ->