Suppose I catch an exception that is of type AppException
but I only want to carry out certain actions on that exception if it has a nested exception of type StreamException
.
if (e instanceof AppException)
{
// only handle exception if it contains a
// nested exception of type 'StreamException'
How do I check for a nested StreamException
?
Do: if (e instanceof AppException and e.getCause() instanceof StreamException)
.