我收到以下代码的未处理异常类型错误,尽管据我了解,我已经在 catch 块中处理了异常。
class NewException extends Exception{
private String msg;
public NewException(String msg){
this.msg = msg;
}
public String getExceptionMsg(){
return msg;
}}
class CatchException {
public static void method () throws NewException{
try {
throw new NewException("New exception thrown");
}
catch (NewException e){
e.printStackTrace();
System.out.println(e.getExceptionMsg());
}
finally {
System.out.println("In finally");
}
}}
public class TestExceptions{
public static void main(String[] args){
CatchException.method();
}}