/**
* 自定义负数异常类
* 由于Exception数据java.lang包下的类,不需要导入
*/
package cn.cnsy123.ypf.exception.test;
/**
* @author yangpf
* @date 2017-02-26 12:53:45
* @description 尝试自定义异常抛出学习
* @extends Exception
*/
public class ObjectTOIntegrException extends Exception {
/**
*
*/
private static final long serialVersionUID = -357063712967783442L;
public ObjectTOIntegrException(){
super();
}
public ObjectTOIntegrException(final String message){
super(message);
}
}
package cn.cnsy123.ypf.exception.test;
public class Demo1 {
public static void main(String[] args){
try{
final String number = "haha";
Integer.parseInt(number);
}catch(Exception e){
throw new ObjectTOIntegrException("抛出转换整形数据异常");
}
}
}