How to catch the exception?

Guys, good morning!

Determined to help me with a question? I am entering an exception action and I am not welcome, I am doing the following:

try {

} catch (Exception e) {

System.out.println (e.getCause ()) // I’ve tried this way

System.out.println (e.getCause (). GetMessage ()) // And this way too

}

but both as forms come null,

how could it be to get a cause? Example:

In the middle of the test an application is unavailable, it has to show that the error regarding the unavailability of the system, among other errors that can happen.

thanks in advance!

Have you tried printing the exception without making a call to getCause(). It’s probable that the cause is null, also are you aware of what kind of exception is being thrown?

How to separate as causes, I understood how it works, but now the doubt has arisen, how can I define them as variables and imports predefined when creating the test case?