Exception handling is crucial for enterprise applications. Exceptions can arise in the middle of execution, such as a PersonCreationException in our example. Once an exception arises somewhere within the execution, the data will either be persisted in the database or the complete transaction will be rolled back, depending on the exception.
For example, let's say our createPerson() function throws PersonCreationException:
public class PersonCreationException extends Exception {
public PersonCreationException(String message) {
super(message)
}
}
Since PersonCreationException is a checked exception, the transaction will not be rolled back if the exception is thrown during the execution of the createPerson() function. These kinds of exceptions are commonly called application exceptions.
Application exceptions are checked exceptions that either have to be handled...