时间的法外狂徒

导航

一个简单的自定义异常

一、自定义异常

public class OneException extends RuntimeException {

    public OneException(String message){
        super(message);
    }
}

二、测试

import org.junit.Test;


public class OneExceptionTest {
    @Test
    public void test(){
        if(1<2){
            throw new OneException("自定义异常");
        }
    }
}

三、结果

com.imooc.order.exception.OneException: 自定义异常

 

posted on 2020-05-12 22:10  抄手砚  阅读(196)  评论(0编辑  收藏  举报