json object for FileNotFound
When a nonexistant file is passed to a command and --json-error-messages is enabled, output a JSON object indicating the problem. (But git ls-files --error-unmatch still displays errors about such files in some situations.) I don't like the duplication of the name of the command introduced by this, but I can't see a great way around it. One way would be to pass the Command instead. When json is not enabled, the stderr is unchanged. This is necessary because some commands like find have custom output. So dislaying "find foo not found" would be wrong. So had to complicate things with toplevelFileProblem having different output with and without json. When not using --json-error-messages but still using --json, it displays the error to stderr, but does display a json object without the error. It does have an errorid though. Unsure how useful that behavior is. Sponsored-by: Dartmouth College's Datalad project
This commit is contained in:
parent
91ba0cc7fd
commit
be36e208c2
29 changed files with 97 additions and 43 deletions
|
@ -0,0 +1,19 @@
|
|||
[[!comment format=mdwn
|
||||
username="joey"
|
||||
subject="""comment 8"""
|
||||
date="2023-04-25T22:45:24Z"
|
||||
content="""
|
||||
Ok, implemented the simple alternative. Here's how it looks:
|
||||
|
||||
joey@darkstar:~/tmp/xxx>git-annex add 'dne' --json --json-error-messages
|
||||
{"command":"add","error-messages":["git-annex: dne not found"],"errorid":"FileNotFound","file":"dne","input":["dne"],"success":false}
|
||||
add: 1 failed
|
||||
|
||||
The errorid will remain stable. I can add those to other error messages
|
||||
now, on request BTW.
|
||||
|
||||
Note that when git-annex relies on `git ls-files --error-unmatch` to
|
||||
complain about nonexistant or non-git files, the error messages from
|
||||
git will still be displayed to stderr, not this nice json. So
|
||||
datalad will need to keep its parser for that part.
|
||||
"""]]
|
Loading…
Add table
Add a link
Reference in a new issue