-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade javaparser and enhance the fail message for parse exceptions #241
Conversation
// The original exception is not useful for the user. We should provide a more informative one | ||
String message = e.getMessage(); | ||
// If the message contains the stack trace, we should remove it. | ||
int index = message.indexOf("Problem stacktrace :"); | ||
message = index == -1 ? message : message.substring(0, index); | ||
System.err.println( | ||
"javaparser was not able to parse file at: " | ||
+ path | ||
+ "\n" | ||
+ message | ||
+ "\n" | ||
+ "Shutting down."); | ||
// Exit with error code 1 to indicate failure. | ||
System.exit(1); | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than printing and calling System.exit
here, why not create a wrapper exception object with the desired message and rethrow that? It just seems like this is not the right place to decide if this is a fatal error that should exit the JVM. Plus, directly calling System.exit
makes it very difficult to write a test for this scenario.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, that sounds better. 7e4dfb1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One nit but otherwise looks good to me
injector/src/main/java/edu/ucr/cs/riple/injector/exceptions/ParseException.java
Outdated
Show resolved
Hide resolved
…rseException.java Co-authored-by: Manu Sridharan <[email protected]>
This PR upgrades the javaparser library to version
3.26.2
and enhances the fail message for parse exceptions, providing more context and clarity.Before this change, a parse exception would display a message like the following, which lacks sufficient context:
With this update, the error message now includes the file path, making it easier to locate the issue:
This change involves both the library upgrade and an improvement to the error message but both are included in this single PR rather than separated due to the small scope of changes.