All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.app.common.exception.CodeException Maven / Gradle / Ivy

The newest version!
package com.app.common.exception;


public class CodeException extends Exception
{
	 private static final long serialVersionUID = -10000000000000L;
	    
	    
	    protected int code = 6003; // 未知错误
	    protected String message = "UnKnown"; // 默认的异常描述
	    
	    public CodeException() // 缺省构造函数
	    {
	        super();
	    }
	    
	    public CodeException(String message) 
	    {
	        super(message);  
	        this.message = message;
	    }
	    
	    public CodeException(int code, String message)
	    {
	        super(message);
	        this.code  = code;
	        this.message = message;
	    }
	    
	    public int code()
	    {
	        return code;
	    }
	    
	    @Override
		public String getMessage()
	    {
	        return "[" + code() +"] " + message;
	    }
	    
	    @Override
		public String toString()
	    {
	        StringBuffer msg = new StringBuffer("");
	        msg.append(this.getMessage()).append(" : \n" + "    Exception by: { \n" + "        by ").append(
	                this.getLocalizedMessage()).append("\n");
	        StackTraceElement[] se = this.getStackTrace();
	        for (int i = 0; i < se.length; i++)
	        {
	            msg.append("        at ").append(se[i].toString()).append("\n");
	        }
	        msg.append("    }\n");
	        return msg.toString();
	    }
	    
	    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy