📄 businessexception.java
字号:
package com.iplan.portal.framework.base;
import java.text.MessageFormat;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.springframework.context.i18n.LocaleContextHolder;
import com.iplan.portal.framework.Constants;
/**
* 基本异常信息类,带有错误代码与错误信息�??
* <p>
* http://www.hao-se.cn
* </p>
*
* @author ws
*/
public class BusinessException extends Exception
{
/**
* 错误代码
*/
private String errorCode = "UNKNOW_ERROR";
static ResourceBundle rb = ResourceBundle.getBundle(Constants.ERROR_BUNDLE_KEY, LocaleContextHolder.getLocale());
/**
* 错误信息中的参数
*/
protected String[] errorArgs = null;
public String getErrorCode()
{
return errorCode;
}
public BusinessException(String errorCode, String[] errorArgs)
{
this.errorCode = errorCode;
this.errorArgs = errorArgs;
}
public BusinessException(String errorCode, String[] errorArgs, Throwable cause)
{
super(cause);
this.errorCode = errorCode;
this.errorArgs = errorArgs;
}
public String getMessage()
{
String message = "";
try
{
message = rb.getString(errorCode);
}
catch (MissingResourceException mse)
{
message = "Can't get the message of the Error Code";
}
message = MessageFormat.format(message, errorArgs);
return errorCode + ": " + message;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -