Skip to content

Replace printStackTrace with proper error propagation#52

Open
micheleh wants to merge 1 commit intomasterfrom
fix/replace-printstacktrace-with-proper-errors
Open

Replace printStackTrace with proper error propagation#52
micheleh wants to merge 1 commit intomasterfrom
fix/replace-printstacktrace-with-proper-errors

Conversation

@micheleh
Copy link
Copy Markdown
Collaborator

@micheleh micheleh commented Apr 4, 2026

Summary

  • Replaced e.printStackTrace() in JunitReportReader (2 occurrences) with throw new RuntimeException(message, e) — errors now propagate to callers instead of being silently swallowed
  • Replaced 6 individual e.printStackTrace() catch blocks in MavenPlugin.execute() with a single multi-catch that throws MojoExecutionException — Maven now reports BUILD FAILURE on errors

Context

All 8 printStackTrace() calls in production code have been present since the initial commit (c71ed1f, 2021-11-15), with 2 added later in f165757. The project has no logging framework, so stack traces were dumped to stderr, leaking internal class names and file paths. Worse, MavenPlugin.execute() returned normally after catching exceptions, causing Maven to report BUILD SUCCESS even when the tool failed completely.

Verification

  • JunitReportReader no longer prints stack traces to stderr on parse errors
  • MavenPlugin.execute() throws MojoExecutionException on processing failure
  • MavenPlugin no longer prints stack traces to stderr
  • Full test suite passes (42 tests, 0 failures)

JunitReportReader now wraps XMLStreamException in RuntimeException
instead of printing stack traces, since Iterator.next() cannot
declare checked exceptions. MavenPlugin now throws
MojoExecutionException instead of swallowing 6 exception types,
so Maven correctly reports BUILD FAILURE on errors.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@micheleh micheleh requested a review from nissimshitrit April 4, 2026 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant