0

我正在编写一个必须抛出异常的函数。我的问题是,当被捕获时,异常始终为空。

这是我的代码的简单版本。该e.printStackTrace()调用将抛出一个NullPointerException

为什么我的异常总是空的?

private void fun2() throws Exception {

    throw new Exception("Test Exception..");
}

private void fun1() {

    try {

        fun2();
    }
    catch (Exception e) {

        e.printStackTrace(); // e is null here, but shouldn't be
    }
}
4

0 回答 0