Merged
Conversation
added 3 commits
December 16, 2025 23:09
- 4.1 Replace 12+ `System.err.println()` calls with a proper logging framework (SLF4J/Logback); locations include `gi-fx/InOut.groovy`, `gi-fx/Viewer.groovy`, `gi-swing/InOut.groovy`. - 4.2 Fix `printStackTrace()` usage in `gi-swing/InOut.groovy:268`; use logger instead. - 4.3 Remove code duplication: `AbstractInOut.getResourceUrl()` and `FileUtils.getResourceUrl()` have nearly identical logic; make one delegate to the other. - 4.4 Add headless environment detection (`GraphicsEnvironment.isHeadless()`) in gi-fx and gi-swing to fail gracefully instead of crashing on headless systems. - 4.5 Document and standardise null handling policy across all methods to favour exceptions; some return null on failure, others throw exceptions.
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request implements comprehensive quality improvements focused on logging infrastructure, error handling standardization, and environment robustness. The changes replace ad-hoc error output with a proper SLF4J logging framework, eliminate code duplication, add headless environment detection to prevent crashes, and formalize null handling policies across the API.
Key Changes:
- Migrated from
System.err.println()andprintStackTrace()to SLF4J logging with parameterized messages across all modules - Added headless environment detection in GUI modules (gi-fx, gi-swing) to fail early with clear error messages
- Refactored
AbstractInOut.getResourceUrl()to delegate toFileUtils.getResourceUrl(), eliminating duplicate resource resolution logic - Formalized and documented null handling and exception policies in the
GuiInteractioninterface
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| gi-swing/InOut.groovy | Added SLF4J logger, headless detection in static initializer, replaced System.err calls with log.error/log.warn |
| gi-fx/Viewer.groovy | Added SLF4J logger, replaced System.err calls with log.error/log.warn |
| gi-fx/InOut.groovy | Added SLF4J logger, headless detection in static initializer, replaced System.err calls with log.error/log.warn |
| gi-console/InOut.groovy | Added SLF4J logger, replaced System.err warning with log.warn |
| GuiInteraction.groovy | Enhanced documentation with formal null handling and exception policies, clarified IllegalArgumentException usage for promptSelect |
| AbstractInOut.groovy | Refactored getResourceUrl() to delegate to FileUtils.getResourceUrl(), removing duplicate code |
| gi-common/build.gradle | Added SLF4J API 2.0.17 as api dependency |
| TODO.md | Marked completed tasks (4.1-4.5) as done, added version 0.2.0 header |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several improvements focused on code quality, error handling, and robustness across the codebase. The most significant changes include replacing direct
System.err.println()calls with a proper logging framework (SLF4J), standardizing null handling and exception policies, delegating resource URL resolution to a single utility method, and adding headless environment detection to prevent crashes in non-GUI environments.Logging and Error Handling Improvements:
System.err.println()andprintStackTrace()calls ingi-fx/InOut.groovy,gi-fx/Viewer.groovy,gi-swing/InOut.groovy, andgi-console/InOut.groovywith SLF4J logging calls (log.warn,log.error). This provides consistent, configurable logging and better error reporting. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16]gi-common/build.gradleto enable logging support throughout the project.Code Quality and Refactoring:
AbstractInOut.getResourceUrl()to delegate toFileUtils.getResourceUrl(), eliminating code duplication and centralizing resource lookup logic.TODO.mdroadmap to mark logging, duplication removal, headless detection, and null handling standardization as completed. [1] [2]Robustness and Environment Detection:
gi-fx/InOut.groovyandgi-swing/InOut.groovy. These modules now throwUnsupportedOperationExceptionif instantiated in a headless environment, preventing runtime crashes and providing clear guidance to use the console version instead. [1] [2]API Documentation and Policy Standardization:
GuiInteraction.groovyinterface documentation to clearly specify null handling and exception policies for all methods, favoring exceptions for invalid input and null returns only for user cancellation or missing resources. Also updated method signatures and documentation to reflect these policies. [1] [2]