Skip to content

Fix exception handling when messages are null#23

Open
ssb22 wants to merge 1 commit into
husonlab:masterfrom
ssb22:master
Open

Fix exception handling when messages are null#23
ssb22 wants to merge 1 commit into
husonlab:masterfrom
ssb22:master

Conversation

@ssb22
Copy link
Copy Markdown

@ssb22 ssb22 commented May 24, 2025

This is a redo of #21 against the modern repository. It changes the code to avoid relying on getMessage() when reporting exceptions, since getMessage() can return null and users find "null" in error messages to be uninformative as shown by issue #18.

The default toString() method itself calls getMessage() and, if it's null, at least returns the class name of the exception, which is better than just "null". Moreover, toString() is called implicitly if we pass a non-String object to println or add it to a string.

While I was at it, I changed a potential null dereference in an exception handler (use "Help".equals(message) not message.equals("Help") because the latter could crash if message is null), and I also cleared the "executable" bit from the permissions of obviously non-executable source files.

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