fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [fineract] xurror commented on a change in pull request #912: add new Logging Guidelines section to README (re. FINERACT-942)
Date Wed, 20 May 2020 11:12:38 GMT

xurror commented on a change in pull request #912:
URL: https://github.com/apache/fineract/pull/912#discussion_r427927795



##########
File path: 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)`).

Review comment:
       ```suggestion
   * 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)`).
   ```
   
   I noticed an extra "`" in the guide. It didn't look good in the preview




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



Mime
View raw message