📄 ourexception.java
字号:
package com.work.exception;
/**
* 当前时间:2007-2-12下午11:25:26
* 所属工程:wshstudy
* @author :wangmj
* @version 0.1
*/
public class OurException extends RuntimeException {
/**
* 无参数构造方法
*/
public OurException() {
super();
}
/**
*
* @param message 客户能够看懂的提示信息!
*/
public OurException(String message) {
super(message);
}
/**
* 这应该是我们最常用的方法。<br>
* 使用方法如下:
* throw new OurException("这是我们自己封装的给客户看的信息!", e);<br>
* 通过<code>OurException.getDetailMessage(Exception e)</code>方法,<br>
* 来获得详细信息的堆栈字符串,这部分信息是给编程人员看的。
* @param message
* @param cause
*/
public OurException(String message, Throwable cause) {
super(message, cause);
}
/**
* 测试主方法。
* @param args
*/
public static void main(String[] args) {
try {
System.out.println("开始测试");
new OurException().test();
} catch (Exception e) {
System.out.println(e.getMessage()+"||");
System.out.println("\n"+ExceptionUtil.getDetailMessage(e));
}
}
/**
* 测试方法。
* @throws OurException
*/
public void test() throws OurException {
try {
try{
throw new Exception("最内层");
}catch(Exception ex){
throw new Exception("第一次捕捉",ex);
}
} catch (Exception e) {
throw new OurException("这是我们自己封装的给客户看的信息!", e);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -