Best practices here will be very similar to those used elsewhere in the Java world:
1. The first lines of a method are usually devoted to checking the validity of the method arguments. The method should work as quickly as possible in case of an error.
When checking the argument, an Exception if the test fails. Often this is one of these excluded exceptions:
IllegalArgumentExceptionNullPointerExceptionIllegalStateException
All of them are retrieved from a RuntimeException .
2. If each object parameter for each method in the class must be non-zero to avoid throwing a NullPointerException , then it is acceptable to specify it once in the general javadoc class instead of repeating it for each method.
Literature:
Preconditions, postconditions and class invariants .
EDIT:
To answer your question about the "specific representation for errors": although it is possible, the idea is that Exception indicates that there are programming errors in the code. Therefore, applications must be allowed to crash so that the user can report an error, and the developer receives error logs from the applicationโs Play Play account. In this way, he can correct the sources of these errors. The process should continue until, hypothetically, the application is completely error free.
source share