异常和错误提示修改

back_recharge
zhangshanxue 2019-10-29 11:33:26 +08:00
parent 6178eb72a5
commit 6189cec63c
3 changed files with 10 additions and 21 deletions

View File

@ -27,7 +27,6 @@ public enum ErrorCode implements IErrorCode {
RELOGIN_CODE(-101, "重复登陆"),
KICK_USER_CODE(-102, "踢用户下线"),
SERVER_SELF_DEFINE(-1, "操作失败"),
SERVER_DEFINE(-1, "操作失败"),
CFG_NULL(-1, "配置不存在"),
@ -139,18 +138,6 @@ public enum ErrorCode implements IErrorCode {
MAP_IN(105,"在地图探索中,不可以操作"),
HERO_LIVE_AGAIN(106,"英雄{0}秒后复活"),
;
private static final Set<Integer> CodeSet = new HashSet<>();
@ -191,12 +178,7 @@ public enum ErrorCode implements IErrorCode {
return errMsg;
}
private ErrorCode reDefineMsg(String errMsg) {
this.errMsg = errMsg;
return this;
}
public static ErrorCode newDefineCode(String errMsg) {
return SERVER_DEFINE.reDefineMsg(errMsg);
public static String newDefineCode(String errMsg) {
return errMsg;
}
}

View File

@ -14,6 +14,11 @@ public class ErrorCodeException extends Exception {
this.errorCode = errorCode;
}
public ErrorCodeException(String message) {
super(message);
errorCode = ErrorCode.SERVER_DEFINE;
}
public ErrorCodeException(ErrorCode errorCode, List<String> params) {
this.errorCode = errorCode;
this.params = params;

View File

@ -3,6 +3,8 @@ package com.ljsd.jieling.handler;
import com.google.protobuf.GeneratedMessage;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.Parser;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.exception.LogicException;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
@ -42,7 +44,7 @@ public abstract class BaseHandler<T extends GeneratedMessage> {
} catch(NoSuchFieldException|SecurityException|IllegalAccessException|IllegalArgumentException|ExceptionInInitializerError|InvalidProtocolBufferException var5){
throw new LogicException("解析协议失败",var5);
}catch (Exception var4) {
if(null !=proto)
if(null !=proto&&!(var4 instanceof ErrorCodeException))
throw new LogicException("processWithProtoException\r\nprotoID:"+netData.getMsgId()+"\r\n"+proto.toString(),var4);
}
}