自定义异常类

--->extends Exception
--->extends Throwable
都一样

 

异常类

 1 package com.yeepay.sxf.exception;
 2 /**
 3  * 验证数据格式异常类
 4  * @author sxf
 5  *
 6  */
 7 public class VoaliteDataSimpleException extends Exception{
 8 
 9     /**
10      * 空构造
11      * e.printStackTrace()==>会打印:报错日志信息(类,方法名,行数)
12      * e.getMessage()==>打印:null
13      */
14     public VoaliteDataSimpleException(){
15         super();
16     }
17     
18     /**
19      * 第一种带参数构造
20      * e.printStackTrace()==>会打印:你输入的信息,报错的日志信息(类,方法名,行数)
21      * e.getMessage()==>仅打印:你输入的信息
22      * @param msg
23      */
24     public VoaliteDataSimpleException(String msg){
25         super(msg);
26     }
27     
28     /**
29      * 第二种构造
30      * @param msg
31      * @param cause
32      * e.printStackTrace()==>会打印:你输入的信息,报错的日志信息(类,方法名,行数),Caused By 内容
33      * e.getMessage()==>仅打印:你输入的信息
34      */
35     public VoaliteDataSimpleException(String msg,Throwable cause){
36         super(msg, cause);
37     }
38     
39     /**
40      * 第三种构造
41      * @param cause
42      *  e.printStackTrace()==>会打印:报错的异常类的全路径:你输入的信息,报错的日志信息(类,方法名,行数),Caused By 内容
43      * e.getMessage()==>仅打印:报错的异常类的全路径:你输入的信息
44      */
45     public VoaliteDataSimpleException(Throwable cause){
46         super(cause);
47     }
48 }
View Code

相关文章:

  • 2021-07-31
  • 2021-12-31
  • 2021-10-24
  • 2021-12-17
  • 2021-07-16
  • 2022-02-10
  • 2022-02-10
猜你喜欢
  • 2021-08-30
  • 2022-02-10
相关资源
相似解决方案