From fc154f91cf3410ba664077be815c2dd4bbb499ea Mon Sep 17 00:00:00 2001 From: Evan Czaplicki Date: Mon, 20 Jan 2014 14:01:53 +0100 Subject: [PATCH] Use Build.Print to show errors --- compiler/Build/Interface.hs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/compiler/Build/Interface.hs b/compiler/Build/Interface.hs index 249c70f..edd929e 100644 --- a/compiler/Build/Interface.hs +++ b/compiler/Build/Interface.hs @@ -4,28 +4,23 @@ module Build.Interface (load,isValid) where import qualified Data.ByteString.Lazy as L import qualified Data.Binary as Binary +import qualified Build.Print as Print import qualified Elm.Internal.Version as Version import System.Directory (doesFileExist) -import System.Exit -import System.IO - import SourceSyntax.Module load :: Binary.Binary a => FilePath -> IO a load filePath = do exists <- doesFileExist filePath case exists of - False -> failure $ "Unable to find file " ++ filePath ++ " for deserialization!" + False -> Print.failure $ "Unable to find file " ++ filePath ++ " for deserialization!" True -> do bytes <- L.readFile filePath case Binary.decodeOrFail bytes of Right (_, _, binaryInfo) -> return binaryInfo - Left (_, offset, err) -> failure $ msg offset err + Left (_, offset, err) -> Print.failure $ msg offset err where - failure err = do hPutStrLn stderr err - exitFailure - msg offset err = concat [ "Error reading build artifact: ", filePath, "\n" , " '", err, "' at offset ", show offset, "\n"