question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove punctuation in Exception messages

See original GitHub issue

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 ...

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jxblumcommented, 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.

1reaction
aml8801commented, 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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Remove punctuation in Exception messages #442 - GitHub
By default, Java concatenates Exception messages in a chained Exception with the ; . If punctuation is used, then this can lead to...
Read more >
How to remove punctuation from a string with ... - Stack Overflow
How to remove punctuation from a string with exceptions using regex in bash · 1. tr does not use regular-expressions. It's syntax superficially ......
Read more >
Removing punctuations from a given string - GeeksforGeeks
Approach: First check the input string if it consists of punctuations then we have to make it punctuation free. In order to do...
Read more >
Python Program to Remove Punctuations From a String
This program removes all punctuations from a string. We will check each character of the string using for loop. If the character is...
Read more >
How to remove punctuation from a string with exceptions ...
[Solved]-How to remove punctuation from a string with exceptions using regex in bash-bash ... You can specify the punctuation marks you want removed,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found