Skip to content

Remove punctuation in Exception messages #2603

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

Closed
jxblum opened this issue Apr 12, 2022 · 11 comments
Closed

Remove punctuation in Exception messages #2603

jxblum opened this issue Apr 12, 2022 · 11 comments
Labels
status: ideal-for-contribution An issue that a contributor can help us with type: task A general task

Comments

@jxblum
Copy link
Contributor

jxblum commented Apr 12, 2022

Many Exception messages contain exclamation marks (!) at the end of the Exception message, for example:

"Object must not be null!"

While this alerts the user to an immediate problem in his/her code, it could be construed as abrasive.

Additionally, using any form of punctuation in Exception messages is not conducive for chaining. Generally, in Java Exception/Error (Throwable) chaining, the messages from the underlying Exceptions (causes) are chained together with the outer, wrapping Exception, for example:

java.lang.IllegalArgumentException: "Message from the wrapping IllegalArgumentException followed by; Message of the caused by Exception"
  at ...
caused by: java.lang.IllegalStateException: Message of the caused by Exception
  at ...

That is, the Exception messages from the chain are appended and separated by the ;.

If the messages from the wrapping Exceptions in the Exception chain contain punctuation, then it can lead to confusing text:

java.lang.IllegalArgumentException: "Object must not be null!; Message of the caused by Exception"
  at...
caused by: java.lang.IllegalStateException: Message of the caused by Exception
  at ...
@jxblum jxblum added type: task A general task status: ideal-for-contribution An issue that a contributor can help us with labels Apr 12, 2022
@aml8801
Copy link

aml8801 commented May 30, 2022

Hallo, I could do this issue. Is it still needed?

@jxblum
Copy link
Contributor Author

jxblum commented Jun 2, 2022

Yes; thank you! If you have questions or need assistance, please post in the comments here. It should be a relatively simple development task though.

@aml8801
Copy link

aml8801 commented Jun 4, 2022

Hallo again. I just wanted to make sure that I'm fulfilling the right task. @jxblum : You want to remove have all punctuation( .;-! etc. ) at the end of all exception messages including the "test-directory", right?

@aml8801
Copy link

aml8801 commented Jun 4, 2022

For cases like:

IllegalStateException(
						String.format("Cannot detect parameter names of copy constructor of %s!", owner.getType()));

The removal of the punctuation seems not useful here, since there is something else added at the end.

@aml8801
Copy link

aml8801 commented Jun 4, 2022

hallo, finishing the first part of the changes.
I've been creating an new feature branch locally and want to push it, while creating a new remote branch. I got the following Error:
remote: Permission to spring-projects/spring-data-commons.git denied to aml8801. unable to access

Am I missing something? Do you create the remote branch? Sorry for the inconvenience
Thanks in advance

@jxblum
Copy link
Contributor Author

jxblum commented Jun 5, 2022

Regarding...

You want to remove have all punctuation( .;-! etc. ) at the end of all exception messages including the "test-directory", right?

Yes

This...

String.format("Cannot detect parameter names of copy constructor of %s!", owner.getType()));

Can be changed to this...

String.format("Cannot detect parameter names of copy constructor of %s", owner.getType()));

The %s is simply a (String) formatting character for the String.format(..) method.

Lastly, involving...

Do you create the remote branch?

In your local topic branch, after you have pushed up to your clone, you can then create PR and submit the changes using the Pull Request process.

Thanks.

@aml8801
Copy link

aml8801 commented Jun 6, 2022

Hallo and thanks to @jxblum for the great support.

I created a fork as a personal project and added the pull request. I checked all instantiations of the occurring exceptions, including messages which are created in advance. Hopefully I did not miss any. The PR is ready for review now.
If there are any cases which could be solved better, I appreciate every further suggestions.
Best regards

@jxblum
Copy link
Contributor Author

jxblum commented Jun 7, 2022

I saw your PR and will review tomorrow (I was on PTO today). Thank you for your contribution! It is very much appreciated.

jxblum pushed a commit to jxblum/spring-data-commons that referenced this issue Jun 8, 2022
jxblum added a commit to jxblum/spring-data-commons that referenced this issue Jun 8, 2022
jxblum pushed a commit to jxblum/spring-data-commons that referenced this issue Jun 8, 2022
jxblum added a commit to jxblum/spring-data-commons that referenced this issue Jun 8, 2022
jxblum added a commit to jxblum/spring-data-commons that referenced this issue Jun 8, 2022
@jxblum jxblum closed this as completed in 6a23723 Jun 8, 2022
@martinsefcik
Copy link

martinsefcik commented Dec 12, 2022

@jxblum @aml8801 I am not sure this was correctly implemented.

For example the following message before (2.5.x) looked like this:
No property creat found for type User! Did you mean 'created'?
Now it looks like this:
No property 'creat' found for type 'User' Did you mean ''created''

No separation between two sentences and doubled quotes for second field name.
And if you don't want to use question mark in question, then probably you should rephrase it to something like: Probably you mean 'created' instead of Did you mean 'created'

@jxblum
Copy link
Contributor Author

jxblum commented Dec 12, 2022

@martinsefcik - Thank you for bringing this to our attention. It would appear that this is the affected area of code and it could do with some more refactoring.

What we would be shooting for in this message is:

No property 'creat' found for type 'User'; Did you mean 'created'

I will look into this.

jxblum added a commit to jxblum/spring-data-commons that referenced this issue Dec 12, 2022
A message like, "No property 'creat' found for type 'User' Did you mean ''created''" is now properly formatted as:
"No property 'creat' found for type 'User'; Did you mean 'created'".

Closes spring-projectsgh-2603.
jxblum added a commit to jxblum/spring-data-commons that referenced this issue Dec 12, 2022
A message like, "No property 'creat' found for type 'User' Did you mean ''created''" is now properly formatted as:
"No property 'creat' found for type 'User'; Did you mean 'created'".

Closes spring-projectsgh-2603.
@jxblum
Copy link
Contributor Author

jxblum commented Dec 12, 2022

See #2750 for resolution details.

jxblum added a commit to jxblum/spring-data-commons that referenced this issue Dec 12, 2022
A message like, "No property 'creat' found for type 'User' Did you mean ''created''" is now properly formatted as:
"No property 'creat' found for type 'User'; Did you mean 'created'".

Closes spring-projectsgh-2603.
jxblum added a commit to jxblum/spring-data-commons that referenced this issue Dec 12, 2022
A message like, "No property 'creat' found for type 'User' Did you mean ''created''" is now properly formatted as:
"No property 'creat' found for type 'User'; Did you mean 'created'".

Closes spring-projectsgh-2603.
jxblum added a commit to jxblum/spring-data-commons that referenced this issue Dec 12, 2022
A message like, "No property 'creat' found for type 'User' Did you mean ''created''" is now properly formatted as:
"No property 'creat' found for type 'User'; Did you mean 'created'".

Closes spring-projectsgh-2603.
michael-simons added a commit to neo4j/neo4j-jdbc that referenced this issue Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ideal-for-contribution An issue that a contributor can help us with type: task A general task
Projects
None yet
Development

No branches or pull requests

3 participants