public static void main(String[] arguments) throws Exception{
try{
memberFunction();
}catch(Exception ex){
err.println("Exception encountered: " + ex.toString());
final Throwable[] suppressedExceptions = ex.getSuppressed();
final int numSuppressed = suppressedExceptions.length;
if (numSuppressed > 0){
err.println("tThere are " + numSuppressed + " suppressed exceptions:");
for (final Throwable exception : suppressedExceptions){
err.println("tt" + exception.toString());
}
}
}
}
//編譯後,發生錯誤顯示 log
//Exception encountered: java.lang.NullPointerException: XXX
//There are 1 suppressed exceptions:
// java.lang.RuntimeException: XXX