Skip to content

Commit

Permalink
Handle errorReports in doctor version 5 (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
ninth-dev authored Jan 5, 2024
1 parent 6a0824b commit 7b053a6
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions core/handle_execute_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,33 @@ def parse_explanations(explanations) -> str:
else:
return ''

def parse_error_reports(error_reports) -> str:
if error_reports:
error_report_labels = OrderedDict(
[
('timestamp', 'Timestamp'),
('uri', 'URI'),
('buildTarget', 'Build Target'),
('errorReportType', 'Type'),
]
)
markdown = "## Error Reports\n"

for error_report in error_reports:
markdown += "#### {}\n".format(error_report.get("name"))
lines = []
lines.append("```")
for field, label in error_report_labels.items():
if error_report.get(field):
lines.append(
"* {0:<14}: {1}".format(label, error_report.get(field))
)
lines.append("```")
markdown += "{}\n".format("\n".join(lines))
markdown += "{}\n\n".format(error_report.get("shortSummary"))
return markdown
else:
return ""

if isinstance(args, list) and args:
content = json.loads(args[0])
Expand Down Expand Up @@ -130,6 +157,7 @@ def parse_explanations(explanations) -> str:

markdown += parse_build_target(folder.get('targets'), doctor_version)
markdown += parse_explanations(folder.get('explanations'))
markdown += parse_error_reports(folder.get('errorReports'))
else:
messages = content.get('messages')
targets = content.get('targets')
Expand Down

0 comments on commit 7b053a6

Please sign in to comment.