Prints the Fire trace and the error to stdout.
(component_trace)
| 276 | |
| 277 | |
| 278 | def _DisplayError(component_trace): |
| 279 | """Prints the Fire trace and the error to stdout.""" |
| 280 | result = component_trace.GetResult() |
| 281 | |
| 282 | output = [] |
| 283 | show_help = False |
| 284 | for help_flag in ('-h', '--help'): |
| 285 | if help_flag in component_trace.elements[-1].args: |
| 286 | show_help = True |
| 287 | |
| 288 | if show_help: |
| 289 | command = f'{component_trace.GetCommand()} -- --help' |
| 290 | print(f'INFO: Showing help with the command {shlex.quote(command)}.\n', |
| 291 | file=sys.stderr) |
| 292 | help_text = helptext.HelpText(result, trace=component_trace, |
| 293 | verbose=component_trace.verbose) |
| 294 | output.append(help_text) |
| 295 | Display(output, out=sys.stderr) |
| 296 | else: |
| 297 | print(formatting.Error('ERROR: ') |
| 298 | + component_trace.elements[-1].ErrorAsStr(), |
| 299 | file=sys.stderr) |
| 300 | error_text = helptext.UsageText(result, trace=component_trace, |
| 301 | verbose=component_trace.verbose) |
| 302 | print(error_text, file=sys.stderr) |
| 303 | |
| 304 | |
| 305 | def _DictAsString(result, verbose=False): |
no test coverage detected