首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Java 自定义异常类【转】

2012-09-10 
Java 自定义错误类【转】原文地址 :[url] http://www.cnblogs.com/likwo/archive/2010/08/03/1791187.html[/

Java 自定义错误类【转】
原文地址 :[url] http://www.cnblogs.com/likwo/archive/2010/08/03/1791187.html[/url]

Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->public class MyException extends Exception{    private static final long serialVersionUID = 1L;    private Type type;        public MyException( Type type )    {        super();        this.type = type;    }    public MyException( Throwable t, Type type )    {        super( t );        this.type = type;    }    public String toString() {        return super.toString() + "<" + getErrorType().getErrorCode() + ">";    }        public Type getErrorType()    {        return type;    }        public enum Type    {        // 系统错误        SYSTEM_ERROR( "99999" ),               // 用户认证错误        USER_AUTH( "03003" );                private String errorCode;        Type( String errorCode )        {            this.errorCode = errorCode;        }        public String getErrorCode()        {            return this.errorCode;        }    }}

热点排行