You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by Apache Wiki <wi...@apache.org> on 2010/04/09 16:48:33 UTC
[Cassandra Wiki] Update of "CodeStyle" by JonathanEllis
Dear Wiki user,
You have subscribed to a wiki page or wiki category on "Cassandra Wiki" for change notification.
The "CodeStyle" page has been changed by JonathanEllis.
http://wiki.apache.org/cassandra/CodeStyle?action=diff&rev1=11&rev2=12
--------------------------------------------------
== Exception handling ==
* Never ever write `catch (...) {}` or `catch (...) { logger.error() }` merely to satisfy Java's compile-time exception checking. Always propagate the exception up or throw RuntimeException (or, if it "can't happen," AssertionError). This makes the exceptions visible to automated tests.
+ * Avoid propagating up checked exceptions that no caller handles. Rethrow as RuntimeException (or IOError, if that is more applicable)
* Similarly, `logger.warn()` is often a cop-out: is this an error or not? If it is don't hide it behind a warn; if it isn't, no need for the warning.
* If you genuinely know an exception indicates an expected condition, it's okay to ignore it BUT this must be explicitly explained in a comment.