Commit 62c255b7 authored by yanzg's avatar yanzg

修改代码

parent 27ffc97d
package com.yanzuoguang.util.exception;
/**
* 途比达异常信息
*
* @author 颜佐光
*/
public class CodeTargetException extends CodeException {
/**
* Constructs a new runtime exception with the specified detail message and
* cause. <p>Note that the detail message associated with
* {@code cause} is <i>not</i> automatically incorporated in
* this runtime exception's detail message.
*
* @param code the detail code (which is saved for later retrieval
* by the {@link #getCode()} method).
* @param message the detail message (which is saved for later retrieval
* by the {@link #getMessage()} method).
* @param cause the cause (which is saved for later retrieval by the
* {@link #getCause()} method). (A <tt>null</tt> value is
* permitted, and indicates that the cause is nonexistent or
* unknown.)
* @since 1.4
*/
public CodeTargetException(String code, String message, Throwable cause) {
super(code, message, cause);
}
/**
* 构造函数
* throw new CodeException("01","该订单已过期",order);
* throw new CodeException("02","该订单未到使用时间",order);
*
* @param message  错误消息
* @param target  错误数据源,如订单数据
*/
public CodeTargetException(String message, Object target) {
super(message, target);
}
/**
* 构造函数
* throw new CodeException("01","该订单已过期",order);
* throw new CodeException("02","该订单未到使用时间",order);
*
* @param message  错误消息
* @param target  错误数据源,如订单数据
* @param cause the cause (which is saved for later retrieval by the
* {@link #getCause()} method). (A <tt>null</tt> value is
* permitted, and indicates that the cause is nonexistent or
* unknown.)
*/
public CodeTargetException(String message, Object target, Throwable cause) {
super(message, target, cause);
}
/**
* 构造函数
* throw new CodeException("01","该订单已过期",order);
* throw new CodeException("02","该订单未到使用时间",order);
*
* @param code  错误码
* @param message  错误消息
* @param target  错误数据源,如订单数据
*/
public CodeTargetException(String code, String message, Object target) {
super(code, message, target);
}
/**
* 构造函数
* throw new CodeException("01","该订单已过期",order);
* throw new CodeException("02","该订单未到使用时间",order);
*
* @param code  错误码
* @param message  错误消息
* @param target  错误数据源,如订单数据
* @param cause the cause (which is saved for later retrieval by the
* {@link #getCause()} method). (A <tt>null</tt> value is
* permitted, and indicates that the cause is nonexistent or
* unknown.)
*/
public CodeTargetException(String code, String message, Object target, Throwable cause) {
super(code, message, target, cause);
}
/**
* Constructs a new runtime exception with the specified detail message and
* cause. <p>Note that the detail message associated with
* {@code cause} is <i>not</i> automatically incorporated in
* this runtime exception's detail message.
*
* @param message the detail message (which is saved for later retrieval
* by the {@link #getMessage()} method).
* @param cause the cause (which is saved for later retrieval by the
* {@link #getCause()} method). (A <tt>null</tt> value is
* permitted, and indicates that the cause is nonexistent or
* unknown.)
* @since 1.4
*/
public CodeTargetException(String message, Throwable cause) {
super(message, cause);
}
/**
* Constructs a new runtime exception with {@code null} as its
* detail message. The cause is not initialized, and may subsequently be
* initialized by a call to {@link #initCause}.
*/
public CodeTargetException() {
super();
}
/**
* Constructs a new runtime exception with the specified detail message.
* The cause is not initialized, and may subsequently be initialized by a
* call to {@link #initCause}.
*
* @param code the detail code (which is saved for later retrieval
* by the {@link #getCode()} method).
* @param message the detail message. The detail message is saved for
* later retrieval by the {@link #getMessage()} method.
*/
public CodeTargetException(String code, String message) {
super(code, message);
}
/**
* Constructs a new runtime exception with the specified detail message.
* The cause is not initialized, and may subsequently be initialized by a
* call to {@link #initCause}.
*
* @param message the detail message. The detail message is saved for
* later retrieval by the {@link #getMessage()} method.
*/
public CodeTargetException(String message) {
super(message);
}
/**
* Constructs a new runtime exception with the specified detail message and
* cause. <p>Note that the detail message associated with
* {@code cause} is <i>not</i> automatically incorporated in
* this runtime exception's detail message.
*
* @param cause the cause (which is saved for later retrieval by the
* {@link #getCause()} method). (A <tt>null</tt> value is
* permitted, and indicates that the cause is nonexistent or
* unknown.)
* @since 1.4
*/
public CodeTargetException(Throwable cause) {
super(cause);
}
}
...@@ -2,7 +2,6 @@ package com.yanzuoguang.util.exception; ...@@ -2,7 +2,6 @@ package com.yanzuoguang.util.exception;
import com.yanzuoguang.util.contants.ResultConstants; import com.yanzuoguang.util.contants.ResultConstants;
import com.yanzuoguang.util.helper.StringHelper; import com.yanzuoguang.util.helper.StringHelper;
import com.yanzuoguang.util.log.Log;
import com.yanzuoguang.util.vo.ResponseResult; import com.yanzuoguang.util.vo.ResponseResult;
/** /**
...@@ -65,7 +64,10 @@ public class ExceptionHelper { ...@@ -65,7 +64,10 @@ public class ExceptionHelper {
* @return 返回的数据 * @return 返回的数据
*/ */
public static ResponseResult getError(Exception e, boolean isFull) { public static ResponseResult getError(Exception e, boolean isFull) {
if (e instanceof RuntimeCodeException) { if (e instanceof CodeTargetException) {
CodeTargetException code = (CodeTargetException) e;
return getError(code.getCode(), code.getMessage(), code.getTarget(), true);
} else if (e instanceof RuntimeCodeException) {
RuntimeCodeException code = (RuntimeCodeException) e; RuntimeCodeException code = (RuntimeCodeException) e;
return getError(code.getCode(), code.getMessage(), code.getTarget(), isFull); return getError(code.getCode(), code.getMessage(), code.getTarget(), isFull);
} else { } else {
......
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