Skip to content

Commit 970bb55

Browse files
committed
report decoding errors explicitly from File.readBinary
1 parent 820e5f8 commit 970bb55

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

builder/src/File.hs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,20 @@ readBinary path =
7878
then
7979
do result <- Binary.decodeFileOrFail path
8080
case result of
81-
Right a -> return (Just a)
82-
Left _ -> return Nothing
81+
Right a ->
82+
return (Just a)
83+
84+
Left (offset, message) ->
85+
do IO.hPutStrLn IO.stderr $ unlines $
86+
[ "+-------------------------------------------------------------------------------"
87+
, "| Corrupt File: " ++ path
88+
, "| Byte Offset: " ++ show offset
89+
, "| Message: " ++ message
90+
, "| Please report this to https://github.com/elm/compiler/issues"
91+
, "| Trying to continue anyway."
92+
, "+-------------------------------------------------------------------------------"
93+
]
94+
return Nothing
8395
else
8496
return Nothing
8597

0 commit comments

Comments
 (0)