Skip to content

Commit

Permalink
TMPCALL
Browse files Browse the repository at this point in the history
  • Loading branch information
mih committed Oct 15, 2024
1 parent dd31280 commit f3b3942
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions datalad_core/runners/annex.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,20 @@ def call_annex_json_lines(
with iter_git_subproc(cmd, cwd=cwd) as annex_proc:
for res in load_json(itemize(annex_proc, sep=None)):
if res.get('success', True) is False:
error_results.append({
k: v for k, v in res.items()
if k in ('command', 'input', 'error-messages', 'note')
})
error_results.append(
{
k: v
for k, v in res.items()
if k in ('command', 'input', 'error-messages', 'note')
}
)
yield res
except CommandError as e:
# TODO: I think we'd rather want to have an exception subclass here
# that can take this information in a structured fashion, and does the
# formatting on access
e.msg = _format_errors(error_results)
raise e
raise


def _format_errors(err: list[dict[str, str | list[str]]]) -> str:
Expand All @@ -79,11 +82,14 @@ def _format_errors(err: list[dict[str, str | list[str]]]) -> str:


def _format_error(err: dict[str, str | list[str]]) -> str:
return ''.join((
f'{err["command"]!r} ' if 'command' in err else '',
'failed',
f' for input {err["input"]!r}' if err.get('input') else '',
f' with {"\n".join(err["error-messages"])!r}'
if err.get('error-messages') else '',
f' [note: {err["note"]}]' if 'note' in err else '',
))
return ''.join(
(
f'{err["command"]!r} ' if 'command' in err else '',
'failed',
f' for input {err["input"]!r}' if err.get('input') else '',
f' with {"\n".join(err["error-messages"])!r}'
if err.get('error-messages')
else '',
f' [note: {err["note"]}]' if 'note' in err else '',
)
)

0 comments on commit f3b3942

Please sign in to comment.