📄 baseexception.java
字号:
package com.ebusiness.ebank.exception;/** * <p>Title: </p> * <p>Description: All other application excetions shall extends this base exception</p> * <p>Copyright: Copyright (c) 2005</p> * <p>Company: eBusiness Inc., All right reserved</p> * @author unascribed * @version 1.0 */import java.io.PrintStream;import java.io.PrintWriter;public class BaseException extends Exception{ private Exception parent; //Exception that causes this Exception private String message; public BaseException(String message, Exception e) { this.message = message; this.parent = e; } public BaseException(Exception e) { this("", e); } public BaseException(String message) { this(message, null); } //Return latest NON-Blank message public String getMessage() { if (this.message == null || this.message.trim().length() == 0) { if (this.parent != null) return this.parent.getMessage(); else return super.getMessage(); } else return this.message; } //Return the direct Exception that causes this Exception public Exception getParentException() { return this.parent; } //Prints this exception and its backtrace to the standard error stream public void printStackTrace() { if (this.parent != null) { System.err.println(this.getClass().getName() + ": " + this.message); System.err.println(" CAUSED BY: "); this.parent.printStackTrace(); } else super.printStackTrace(); } //Prints this exception and its backtrace to the specified print stream public void printStackTrace(PrintStream s) { if (this.parent != null) { s.println(this.getClass().getName() + ": " + this.message); s.println(" CAUSED BY: "); this.parent.printStackTrace(s); } else super.printStackTrace(); } //Prints this exception and its backtrace to the specified print writer public void printStackTrace(PrintWriter s) { if (this.parent != null) { s.println(this.getClass().getName() + ": " + this.message); s.println(" CAUSED BY: "); this.parent.printStackTrace(s); } else super.printStackTrace(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -