--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
|
@ -31,7 +31,7 @@ bpoldrack makes a good point
|
|||
|
||||
So eg:
|
||||
|
||||
{"exception":"UNIQUEID", "file":"foo", "error-messages":["foo not found"]}
|
||||
{"exception":"UNIQUEID", "file":"foo", "message":"foo not found"}
|
||||
|
||||
That seems about right to me, and it future proofs git-annex to be able to
|
||||
report other exceptions in json output later on.
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
[[!comment format=mdwn
|
||||
username="joey"
|
||||
subject="""comment 5"""
|
||||
date="2023-04-25T18:43:20Z"
|
||||
content="""
|
||||
I've implemented --json-exceptions:
|
||||
|
||||
joey@darkstar:~/tmp/xxx>git-annex add dne --json-exceptions
|
||||
{"exception":"FileNotFound","file":"dne","message":"git-annex: dne not found\n"}
|
||||
add: 1 failed
|
||||
|
||||
Note that when a command like `git-annex get` is run on a file that exists,
|
||||
but is not checked into git, `git ls-files` still displays its own error message,
|
||||
so --json-exceptions doesn't help with this:
|
||||
|
||||
joey@darkstar:~/tmp/xxx>touch foo
|
||||
joey@darkstar:~/tmp/xxx>git-annex get foo --json-exceptions
|
||||
error: pathspec 'foo' did not match any file(s) known to git
|
||||
Did you forget to 'git add'?
|
||||
get: 1 failed
|
||||
|
||||
Datalad will still have to parse the git output if it wants to know what file
|
||||
it failed on in that case.
|
||||
"""]]
|
Loading…
Add table
Add a link
Reference in a new issue