Commit 2687e396 by stylefeng

整理异常

parent c4694d96
package com.stylefeng.guns.common.exception; package com.stylefeng.guns.common.exception;
import com.stylefeng.guns.core.exception.GunsException;
/** /**
* @Description 业务异常的封装
* @author fengshuonan * @author fengshuonan
* @Description 业务异常的封装
* @date 2016年11月12日 下午5:05:10 * @date 2016年11月12日 下午5:05:10
*/ */
@SuppressWarnings("serial") public class BussinessException extends GunsException {
public class BussinessException extends RuntimeException{
//友好提示的code码
private int friendlyCode;
//友好提示
private String friendlyMsg;
//业务异常跳转的页面
private String urlPath;
public BussinessException(BizExceptionEnum bizExceptionEnum){
this.friendlyCode = bizExceptionEnum.getCode();
this.friendlyMsg = bizExceptionEnum.getMessage();
this.urlPath = bizExceptionEnum.getUrlPath();
}
public int getCode() {
return friendlyCode;
}
public void setCode(int code) {
this.friendlyCode = code;
}
public String getMessage() {
return friendlyMsg;
}
public void setMessage(String message) {
this.friendlyMsg = message;
}
public String getUrlPath() {
return urlPath;
}
public void setUrlPath(String urlPath) { public BussinessException(BizExceptionEnum bizExceptionEnum) {
this.urlPath = urlPath; super(bizExceptionEnum.getCode(), bizExceptionEnum.getMessage(), bizExceptionEnum.getUrlPath());
} }
} }
/**
* Copyright (c) 2015-2017, Chill Zhuang 庄骞 (smallchill@163.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.stylefeng.guns.common.exception;
import com.stylefeng.guns.core.support.StrKit;
/**
* 工具类初始化异常
*/
public class ToolBoxException extends RuntimeException{
private static final long serialVersionUID = 8247610319171014183L;
public ToolBoxException(Throwable e) {
super(e.getMessage(), e);
}
public ToolBoxException(String message) {
super(message);
}
public ToolBoxException(String messageTemplate, Object... params) {
super(StrKit.format(messageTemplate, params));
}
public ToolBoxException(String message, Throwable throwable) {
super(message, throwable);
}
public ToolBoxException(Throwable throwable, String messageTemplate, Object... params) {
super(StrKit.format(messageTemplate, params), throwable);
}
}
package com.stylefeng.guns.core.exception; package com.stylefeng.guns.core.exception;
/** /**
* @Description 业务异常的封装
* @author fengshuonan * @author fengshuonan
* @Description 业务异常的封装
* @date 2016年11月12日 下午5:05:10 * @date 2016年11月12日 下午5:05:10
*/ */
@SuppressWarnings("serial") public class GunsException extends RuntimeException {
public class GunsException extends RuntimeException{
//友好提示的code码 //友好提示的code码
private int friendlyCode; protected int friendlyCode;
//友好提示 //友好提示
private String friendlyMsg; protected String friendlyMsg;
//业务异常跳转的页面 //业务异常跳转的页面
private String urlPath; protected String urlPath;
public GunsException(GunsExceptionEnum bizExceptionEnum){ protected GunsException(int friendlyCode, String friendlyMsg, String urlPath) {
this.friendlyCode = bizExceptionEnum.getCode(); this.setValues(friendlyCode, friendlyMsg, urlPath);
this.friendlyMsg = bizExceptionEnum.getMessage(); }
this.urlPath = bizExceptionEnum.getUrlPath();
public GunsException(GunsExceptionEnum bizExceptionEnum) {
this.setValues(bizExceptionEnum.getCode(), bizExceptionEnum.getMessage(), bizExceptionEnum.getUrlPath());
}
private void setValues(int friendlyCode, String friendlyMsg, String urlPath) {
this.friendlyCode = friendlyCode;
this.friendlyMsg = friendlyMsg;
this.urlPath = urlPath;
} }
public int getCode() { public int getCode() {
...@@ -46,5 +53,4 @@ public class GunsException extends RuntimeException{ ...@@ -46,5 +53,4 @@ public class GunsException extends RuntimeException{
public void setUrlPath(String urlPath) { public void setUrlPath(String urlPath) {
this.urlPath = urlPath; this.urlPath = urlPath;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment