Quantcast
Channel: Code:Q
Viewing all articles
Browse latest Browse all 50

All exception constructors should take a String parameter

$
0
0


I've spent several days in code reviews. I kept seeing Exception classes with empty constructors, and that just drives me nuts. I also saw exception constructors taking only a Throwable. That drives me nuts almost as bad. After a few days I realized what the programming recommendation should be:
  • All exception constructors should take at least a String parameter
They may take more than a String, of course, such as a Throwable, or an extra int, but there must be at least a String parameter.

Oh, and programmers that write
   throw new FooException("");
should be flogged.


Viewing all articles
Browse latest Browse all 50

Trending Articles