Copilot commented on code in PR #13147:
URL: https://github.com/apache/trafficserver/pull/13147#discussion_r3212602227


##########
tools/hrw4u/src/common.py:
##########
@@ -112,6 +113,43 @@ def fatal(message: str) -> NoReturn:
     sys.exit(1)
 
 
+def _build_formatter(error_format: str):
+    """Instantiate the configured error formatter, falling back to plain."""
+    return FORMATTERS.get(error_format, FORMATTERS["plain"])()

Review Comment:
   `_build_formatter()` is missing a return type annotation, which breaks the 
project-wide convention of fully-typed function signatures in this module. 
Please annotate it (e.g., returning `ErrorFormatter`) so type-checking and IDEs 
can follow the formatter plumbing correctly.



##########
tools/hrw4u/src/common.py:
##########
@@ -181,15 +220,15 @@ def create_parse_tree(
                 error_collector.add_error(e)
             return None, parser_obj, error_collector
         else:
-            fatal(str(e))
+            emit_fatal_error(error_format, e)
     except Exception as e:
         if collect_errors:
             if error_collector:
                 syntax_error = Hrw4uSyntaxError(filename, 0, 0, 
f"{error_prefix} error: {e}", "")
                 error_collector.add_error(syntax_error)
             return None, parser_obj, error_collector
         else:
-            fatal(f"{filename}:0:0 - {error_prefix} error: {e}")
+            emit_fatal_message(error_format, f"{filename}:0:0 - {error_prefix} 
error: {e}", filename=filename)

Review Comment:
   In the stop-on-error path, `emit_fatal_message()` is called with a message 
that already embeds a `filename:line:col` prefix (`f"{filename}:0:0 - ..."`). 
For structured formats (JSON/Markdown), this duplicates location information 
(and makes `message` harder for consumers to parse/search). Pass the plain 
message (consistent with the collecting-errors path which uses 
`f"{error_prefix} error: {e}"`) and rely on the separate `filename/line/column` 
fields instead.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to