--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
|
@ -9,6 +9,7 @@ module Types.Messages where
|
|||
|
||||
import qualified Utility.Aeson as Aeson
|
||||
import Utility.Metered
|
||||
import Utility.RawFilePath
|
||||
|
||||
import Control.Concurrent
|
||||
import System.Console.Regions (ConsoleRegion)
|
||||
|
@ -26,6 +27,7 @@ data OutputType
|
|||
data JSONOptions = JSONOptions
|
||||
{ jsonProgress :: Bool
|
||||
, jsonErrorMessages :: Bool
|
||||
, jsonExceptions :: Bool
|
||||
}
|
||||
deriving (Show)
|
||||
|
||||
|
@ -33,6 +35,7 @@ adjustOutputType :: OutputType -> OutputType -> OutputType
|
|||
adjustOutputType (JSONOutput old) (JSONOutput new) = JSONOutput $ JSONOptions
|
||||
{ jsonProgress = jsonProgress old || jsonProgress new
|
||||
, jsonErrorMessages = jsonErrorMessages old || jsonErrorMessages new
|
||||
, jsonExceptions = jsonExceptions old || jsonExceptions new
|
||||
}
|
||||
adjustOutputType _old new = new
|
||||
|
||||
|
@ -70,6 +73,7 @@ newMessageState = do
|
|||
data SerializedOutput
|
||||
= OutputMessage S.ByteString
|
||||
| OutputError String
|
||||
| OutputException String (Maybe RawFilePath) String
|
||||
| BeginProgressMeter
|
||||
| UpdateProgressMeterTotalSize TotalSize
|
||||
| UpdateProgressMeter BytesProcessed
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue