Conversation
Replace `System.exit(1)` call when `sany.xsd` schema file is not found with `XMLExportingException` containing `FileNotFoundException` as the cause. This allows XMLExporter to be used as a library where the caller can handle the exception instead of having the JVM terminated. Also make the run() method public to provide a library-friendly API that throws exceptions rather than calling System.exit. The System.exit(1) call was introduced in PR #1054 (commit 6d0d6e4) for one error case while similar error cases used exceptions, creating an inconsistency in error handling. [Refactor][XMLExporter] Signed-off-by: Markus Alexander Kuppe <github.com@lemmster.de>
2 tasks
There was a problem hiding this comment.
Pull request overview
This pull request refactors error handling in XMLExporter and SANY to replace System.exit() calls with exceptions, enabling these components to be used as libraries where callers can handle errors without JVM termination.
Changes:
- Introduced new
SANYExitExceptionclass to encapsulate exit codes and error messages - Modified
SANY.javato createSANYmain0()method that throwsSANYExitExceptioninstead of callingSystem.exit() - Modified
XMLExporter.javato throwXMLExportingExceptioninstead of callingSystem.exit()when schema file is missing
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| tlatools/org.lamport.tlatools/src/tla2sany/drivers/SANYExitException.java | New exception class to wrap exit codes and messages for library usage |
| tlatools/org.lamport.tlatools/src/tla2sany/drivers/SANY.java | Added SANYmain0() that throws SANYExitException; SANYmain() wraps it for backward compatibility |
| tlatools/org.lamport.tlatools/src/tla2sany/xml/XMLExporter.java | Made run() method public; replaced System.exit() with XMLExportingException for missing schema file |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tlatools/org.lamport.tlatools/src/tla2sany/drivers/SANYExitException.java
Outdated
Show resolved
Hide resolved
Replace `System.exit()` calls in SANY's command-line argument parsing with `SANYExitException` thrown from a new `SANYmain0()` method. This allows SANY to be used as a library where the caller can handle the exception instead of having the JVM terminated. The existing `SANYmain()` method now wraps `SANYmain0()` with a try-catch that calls System.exit() to maintain backwards compatibility for command-line usage. This continues the refactoring started in the XMLExporter to eliminate System.exit calls throughout the codebase, making components more suitable for library usage. [Refactor][SANY] Signed-off-by: Markus Alexander Kuppe <github.com@lemmster.de>
Contributor
|
Does this change the output of SANY when run at the command line so it ends with a stack trace? |
Member
Author
No |
Calvin-L
approved these changes
Feb 5, 2026
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.
Replace
System.exit(1)calls in XMLExporter and SANY to be used as a library where the caller can handle the exception instead of having the JVM terminated.[Refactor][XMLExporter][SANY]