私は J2ME アプリケーションを開発しており、例外処理の良い習慣を作りたいと思っています。次のようないくつかの例外をスローしています。
ConnectionNotFoundException, IOException, XmlPullParserException, OutOfMemory, Exception
作成する各メソッドでこれらすべての例外をキャッチしたくありません
だから私は新しいクラスを作ることができると思います
このクラスは他のすべてを処理します
私はこのクラスを作りました
public class ExceptionHandler extends Exception {
    private Exception thrownException;
    public ExceptionHandler(Exception thrownExc) {
        this.thrownException = thrownExc;
        if (thrownException.getClass().isInstance(ConnectionNotFoundException.class)) {
            // DO SOMETHING
        } else if (thrownException.getClass().isInstance(IOException.class)) {
            // DO SOMETHING
        } else if (thrownException.getClass().isInstance(XmlPullParserException.class)) {
            // DO SOMETHING
        } else if (thrownException.getClass().isInstance(NullPointerException.class)) {
            // DO SOMETHING
        } else if (thrownException.getClass().isInstance(OutOfMemoryError.class)) {
            // DO SOMETHING
        } else if (thrownException.getClass().isInstance(Exception.class)) {
            // DO SOMETHING
        }
    }
}
しかし、それが良い方法であるかどうかはわかりません。また、スローされた例外を私のものに置き換えるとエラーが発生します
どうすればいいですか?