git.iko.soy/typeable/pandoc
on master help sign in
Fix out of index error in handleError
be47831Matthew Pickering
src/Text/Pandoc/Error.hs+8−4
@@ -62,8 +62,12 @@ handleError (Left err) =
62 let errPos = errorPos err'
62 let errPos = errorPos err'
63 errLine = sourceLine errPos
63 errLine = sourceLine errPos
64 errColumn = sourceColumn errPos
64 errColumn = sourceColumn errPos
65− theline = (lines input ++ [""]) !! (errLine - 1)
65+ ls = lines input ++ [""]
66+ errorInFile = if length ls > errLine - 1
67+ then concat ["\n", (ls !! (errLine - 1))
68+ ,"\n", replicate (errColumn - 1) ' '
69+ ,"^"]
70+ else ""
66− in error $ "\nError at " ++ show err' ++ "\n" ++
71+ in error $ "\nError at " ++ show err'
67− theline ++ "\n" ++ replicate (errColumn - 1) ' ' ++
72+ ++ errorInFile
68− "^"
69
73