From 3b1144988c49c1221b1c5f6b8f7544f1dea7cb44 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Tue, 27 Sep 2022 15:45:38 +0300 Subject: Show position info in error messages --- app/Main.hs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/Main.hs b/app/Main.hs index be5bdf3..d8fcb61 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -29,8 +29,10 @@ repl config env = do Just input -> do result <- lift $ runL config (runInlineScript "" env input) case result of - Left (LException ex) -> do - outputStrLn $ "Error: " ++ ex + Left (LException mp ex) -> do + outputStrLn $ case mp of + Just p -> p ++ " error: " ++ ex + Nothing -> "error: " ++ ex repl config env Right (newEnv, _) -> do repl config newEnv @@ -65,7 +67,9 @@ main = do Just scriptFileName -> do result <- runL config (runScriptFile builtinEnv scriptFileName) case result of - Left (LException ex) -> putStrLn $ "Error: " ++ ex + Left (LException mp ex) -> case mp of + Just p -> putStrLn $ p ++ " error: " ++ ex + Nothing -> putStrLn $ "error: " ++ ex Right _ -> return () Nothing -> do putStrLn $ "Lang REPL" -- cgit v1.3