This is an automated email from the ASF dual-hosted git repository.

vorburger pushed a commit to branch vorburger-README-LoggingGuidelines
in repository https://gitbox.apache.org/repos/asf/fineract.git

commit 25dff61af692d35914131148c1def345985214aa
Author: Michael Vorburger ⛑️ <[email protected]>
AuthorDate: Tue May 19 23:28:04 2020 +0200

     add new Logging Guidelines section to README (re. FINERACT-942)
---
 README.md | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/README.md b/README.md
index bdffaf0..3faa503 100644
--- a/README.md
+++ b/README.md
@@ -268,6 +268,13 @@ Governance and Policies
 documents the process through which you can become a committer in this project.
 
 
+Logging Guidelines
+------------------
+* Never, ever, use `System.out` and `System.err` or `printStackTrace()` 
anywhere, but `LOG.info()` or `LOG.error()` instead.
+* When catching exceptions, either rethrow them, or log them.  Either way, 
include the root cause by using `catch (SomeException e)` and then either 
`throw AnotherException("..details..", e)` or `LOG.error("...context...", e)`.
+* In tests, you'll typically never catch exceptions, but just propagate them, 
with `@Test void testXYZ() throws SomeException, AnotherException`...`, so that 
the test fails if the exception happens.  Unless you actually really want to 
test for the occurence of a problem - in that case, use [JUnit's 
Assert.assertThrows()](https://github.com/junit-team/junit4/wiki/Exception-testing)
 (but not `@Test(expected = SomeException.class)`).
+* Never catch `NullPointerException` & Co.
+
 Pull Requests
 -------------
 

Reply via email to