Add CircularReference constructor to LogMessage.

This commit is contained in:
John MacFarlane 2017-02-15 17:35:29 +01:00
parent 93f0a9c2e5
commit ebe4072bd9

View file

@ -61,6 +61,7 @@ data LogMessage =
| DuplicateLinkReference String SourcePos
| DuplicateNoteReference String SourcePos
| ReferenceNotFound String SourcePos
| CircularReference String SourcePos
| ParsingUnescaped String SourcePos
| CouldNotLoadIncludeFile String SourcePos
| ParsingTrace String SourcePos
@ -106,6 +107,12 @@ instance ToJSON LogMessage where
"source" .= Text.pack (sourceName pos),
"line" .= toJSON (sourceLine pos),
"column" .= toJSON (sourceColumn pos)]
CircularReference s pos ->
["type" .= String "CircularReference",
"contents" .= Text.pack s,
"source" .= Text.pack (sourceName pos),
"line" .= toJSON (sourceLine pos),
"column" .= toJSON (sourceColumn pos)]
ParsingUnescaped s pos ->
["type" .= String "ParsingUnescaped",
"contents" .= Text.pack s,
@ -176,6 +183,8 @@ showLogMessage msg =
"Duplicate note reference '" ++ s ++ "' at " ++ showPos pos
ReferenceNotFound s pos ->
"Reference not found for '" ++ s ++ "' at " ++ showPos pos
CircularReference s pos ->
"Circular reference '" ++ s ++ "' at " ++ showPos pos
ParsingUnescaped s pos ->
"Parsing unescaped '" ++ s ++ "' at " ++ showPos pos
CouldNotLoadIncludeFile fp pos ->
@ -208,6 +217,7 @@ messageVerbosity msg =
DuplicateLinkReference{} -> WARNING
DuplicateNoteReference{} -> WARNING
ReferenceNotFound{} -> WARNING
CircularReference{} -> WARNING
CouldNotLoadIncludeFile{} -> WARNING
ParsingUnescaped{} -> INFO
ParsingTrace{} -> DEBUG