fix:journal: consistent error message when include has no argument
This commit is contained in:
parent
92a3ea48f9
commit
00f6a832d4
@ -304,16 +304,21 @@ includedirectivep iopts = do
|
|||||||
-- save the position at start of include directive, for error messages
|
-- save the position at start of include directive, for error messages
|
||||||
eoff <- getOffset
|
eoff <- getOffset
|
||||||
pos <- getSourcePos
|
pos <- getSourcePos
|
||||||
|
let errorNoArg = customFailure $ parseErrorAt eoff "include needs a file path or glob pattern argument"
|
||||||
|
|
||||||
-- parse the directive
|
-- parse the directive
|
||||||
string "include"
|
string "include"
|
||||||
lift skipNonNewlineSpaces1
|
-- notFollowedBy newline <?> "a file path or glob pattern argument"
|
||||||
prefixedglob <- rstrip . T.unpack <$> takeWhileP Nothing (`notElem` [';','\n'])
|
prefixedglob <- (do
|
||||||
lift followingcommentp
|
lift skipNonNewlineSpaces1
|
||||||
|
prefixedglob <- rstrip . T.unpack <$> takeWhileP Nothing (`notElem` [';','\n'])
|
||||||
|
lift followingcommentp
|
||||||
|
return prefixedglob
|
||||||
|
) <|> errorNoArg
|
||||||
|
|
||||||
let (mprefix,glb) = splitReaderPrefix prefixedglob
|
let (mprefix,glb) = splitReaderPrefix prefixedglob
|
||||||
parentf <- sourcePosFilePath pos -- a little slow, don't do too often
|
parentf <- sourcePosFilePath pos -- a little slow, don't do too often
|
||||||
when (null $ dbg6 (parentf <> " include: glob pattern") glb) $
|
when (null $ dbg6 (parentf <> " include: glob pattern") glb) errorNoArg
|
||||||
customFailure $ parseErrorAt eoff $ "include needs a file path or glob pattern argument"
|
|
||||||
|
|
||||||
-- Find the file or glob-matched files (just the ones from this include directive), with some IO error checking.
|
-- Find the file or glob-matched files (just the ones from this include directive), with some IO error checking.
|
||||||
-- Also report whether a glob pattern was used, and not just a literal file path.
|
-- Also report whether a glob pattern was used, and not just a literal file path.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user