Java异常处理的基本封装
2006-06-08 14:32
295 查看
以下是本人对EXCEPTION的基本封装,以后的异常继承此BASE类,继续扩展.给大家一个异常初步的编写.
package jp.co.yachiyobank.inf.com.frw.baseExp;
import java.io.PrintStream;
import java.io.PrintWriter;
public class BaseException extends Exception{
private static final long serialVersionUID = 1L;
private Throwable throwable;
/**
* クラスのコンストラクタ
* @param なし
*/
public BaseException(){
super();
}
/**
* クラスのコンストラクタ
* @param msg エラーメッセージ
*/
public BaseException(String msg){
super(msg);
}
/**
* クラスのコンストラクタ
* @param msg エラーメッセージ
* @param throwable
*/
public BaseException(String msg,Throwable throwable){
super(msg,throwable);
}
/**
*
* @param なし
*/
public Throwable getException(){
throwable=super.getCause();
return throwable;
}
/**
*
* @param なし
*/
public void printStackTrace(){
super.printStackTrace();
}
/**
*
* @param printStream
*/
public void printStackTrace(PrintStream printStream){
super.printStackTrace(printStream);
}
/**
*
* @param printWriter
*/
public void printStackTrace(PrintWriter printWriter){
super.printStackTrace(printWriter);
}
}
package jp.co.yachiyobank.inf.com.frw.baseExp;
import java.io.PrintStream;
import java.io.PrintWriter;
public class BaseException extends Exception{
private static final long serialVersionUID = 1L;
private Throwable throwable;
/**
* クラスのコンストラクタ
* @param なし
*/
public BaseException(){
super();
}
/**
* クラスのコンストラクタ
* @param msg エラーメッセージ
*/
public BaseException(String msg){
super(msg);
}
/**
* クラスのコンストラクタ
* @param msg エラーメッセージ
* @param throwable
*/
public BaseException(String msg,Throwable throwable){
super(msg,throwable);
}
/**
*
* @param なし
*/
public Throwable getException(){
throwable=super.getCause();
return throwable;
}
/**
*
* @param なし
*/
public void printStackTrace(){
super.printStackTrace();
}
/**
*
* @param printStream
*/
public void printStackTrace(PrintStream printStream){
super.printStackTrace(printStream);
}
/**
*
* @param printWriter
*/
public void printStackTrace(PrintWriter printWriter){
super.printStackTrace(printWriter);
}
}
相关文章推荐
- java异常与错误处理基本知识
- Java异常处理和File基本操作
- 黑马程序员-JAVA-常见异常与基本处理
- java中的 FileWriter类 和 FileReader类的一些基本用法包括对于异常的处理
- Java系统中异常封装处理
- Java总结第二篇 异常处理--基本概念
- java异常处理
- Tomcat:IOException while loading persisted sessions: java.io.EOFException异常处理
- JAVA一般异常处理
- 艾伟_转载:WCF基本异常处理模式[上篇]
- java异常处理规范之finally
- java异常处理中throw和throws的区别?
- JAVA基础——异常处理
- java异常处理机制
- JAVA-JSP内置对象之exception对象用来处理错误异常
- Java_异常处理
- Java异常处理
- java 异常处理
- 有效处理Java异常三原则
- 关于java异常处理的一套面试题