From 29f1d1b22b240ee9ef3cf4b867bc7a663d8d3a6a Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Thu, 8 Dec 2022 17:26:43 +0200 Subject: Improve error reporting --- app/Main.hs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'app') diff --git a/app/Main.hs b/app/Main.hs index 1617dd5..37844c9 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -36,10 +36,8 @@ repl' lineNo ls = do Just input -> do result <- lift $ runL ls $ runInlineScript' lineNo "" input case result of - Left (LException mp ex) -> do - outputStrLn $ case mp of - Just p -> p ++ " error: " ++ ex - Nothing -> "error: " ++ ex + Left ex -> do + outputStrLn $ foldStackMessage ex repl' (lineNo + 1) ls Right (_, LState { stateEnv = newEnv }) -> do repl' (lineNo + 1) ls { stateEnv = newEnv } @@ -86,9 +84,8 @@ main = do Just scriptFileName -> do result <- runL ls (runScriptFile scriptFileName) case result of - Left (LException mp ex) -> case mp of - Just p -> putStrLn $ p ++ " error: " ++ ex - Nothing -> putStrLn $ "error: " ++ ex + Left ex -> do + putStrLn $ foldStackMessage ex Right (_, LState { stateEnv = evaledEnv }) -> do when (configUseREPL config) $ runInputT defaultSettings $ repl ls { stateEnv = evaledEnv } -- cgit v1.3