--json-exceptions
Added a --json-exceptions option, which makes some exceptions be output in json. The distinction is that --json-error-messages is for messages relating to a particular ActionItem, while --json-exceptions is for messages that are not, eg ones for a file that does not exist. It's unfortunate that we need two switches with such a fine distinction between them, but I'm worried about maintaining backwards compatability in the json output, to avoid breaking anything that parses it, and this was the way to make sure I didn't. toplevelWarning is generally used for the latter kind of message. And the other calls to toplevelWarning could be converted to showException. The only possible gotcha is that if toplevelWarning is ever called after starting acting on a file, it will add to the --json-error-messages of the json displayed for that file and converting to showException would be a behavior change. That seems unlikely, but I didn't convery everything to avoid needing to satisfy myself it was not a concern. Sponsored-by: Dartmouth College's Datalad project
This commit is contained in:
parent
a474c9c63b
commit
a325524454
32 changed files with 304 additions and 81 deletions
22
Messages.hs
22
Messages.hs
|
@ -27,6 +27,8 @@ module Messages (
|
|||
showEndFail,
|
||||
showEndResult,
|
||||
endResult,
|
||||
ExceptionId(..),
|
||||
showException,
|
||||
toplevelWarning,
|
||||
warning,
|
||||
earlyWarning,
|
||||
|
@ -197,6 +199,26 @@ endResult :: Bool -> S.ByteString
|
|||
endResult True = "ok"
|
||||
endResult False = "failed"
|
||||
|
||||
{- Unique ids for different exceptions. Do not change the constructors. -}
|
||||
data ExceptionId
|
||||
= FileNotFound
|
||||
| FileBeyondSymbolicLink
|
||||
deriving (Show)
|
||||
|
||||
{- Displays an message that is not associated with any file being
|
||||
- processed. -}
|
||||
showException :: Bool -> ExceptionId -> StringContainingQuotedPath -> Annex ()
|
||||
showException makeway eid msg = do
|
||||
when makeway $
|
||||
outputMessage JSON.none id "\n"
|
||||
outputException (show eid) (mentionedfile msg)
|
||||
("git-annex: " <> msg <> "\n")
|
||||
where
|
||||
mentionedfile (QuotedPath p) = Just p
|
||||
mentionedfile (a :+: b) = mentionedfile a <|> mentionedfile b
|
||||
mentionedfile (UnquotedString _) = Nothing
|
||||
mentionedfile (UnquotedByteString _) = Nothing
|
||||
|
||||
toplevelWarning :: Bool -> StringContainingQuotedPath -> Annex ()
|
||||
toplevelWarning makeway s = warning' makeway id ("git-annex: " <> s)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue