異常紛失の場合に注意
package com.lwf.thinking.eight;
import java.sql.SQLException;
public class UserDefineException {
public static void main(String[] args) throws Exception{
UserDefineException u = new UserDefineException();
try {
u.throwException();
} finally{
u.catchException();
}
}
public static void catchException() throws EusException{
throw new EusException();
}
public static void throwException() throws EusBusiException {
throw new EusBusiException();
}
}
対応する例外クラスEusExceptionとEusBusiExceptionは、単純にExceptionクラスを継承するだけです.
出力結果:
Exception in thread "main"com.lwf.thinking.eight.EusException at com.lwf.thinking.eight.UserDefineException.catchException(UserDefineException.java:17) at com.lwf.thinking.eight.UserDefineException.main(UserDefineException.java:12)結果からEusBusiException異常が失われていることがわかります.これはJAVAの重要な欠陥です.の