Custom Exception class shows Unreachable catch block everytime

后端 未结 4 692
無奈伤痛
無奈伤痛 2021-01-21 11:59

I\'ve created a custom Exception class that I want to use in my application:

public class MyException extends Exception {
    private static final long serialVer         


        
4条回答
  •  遇见更好的自我
    2021-01-21 12:41

    Can you try with:

    try {
        System.out.println("this");
        throw new MyException();
    } catch (MyException  e) {
        // TODO: handle exception
    }
    

    Your exception wasn't thrown anywhere in the code. (try extending RuntimeException as another option)

提交回复
热议问题