未找到英雄异常

master_otnew
grimm 2024-01-15 16:24:44 +08:00
parent 3147706388
commit 12d46dfacd
3 changed files with 18 additions and 5 deletions

View File

@ -1,6 +1,6 @@
package com.ljsd.jieling.exception;
import config.SErrorCodeEerverConfig;
import config.SErrorCodeHint;
import util.StringUtil;
import java.util.ArrayList;
@ -28,10 +28,10 @@ public class ErrorTableException extends Exception {
}
public ErrorTableException(int id) {
String message = SErrorCodeEerverConfig.errorTableMap.get(id);
String message = SErrorCodeHint.errorMap.get(id);
if (StringUtil.isEmpty(message)){
this.id = -1;
this.msg = "操作失败,并未找到错误码:{"+id+"},请联系管理员";
this.msg = "发现异常,并未找到错误码:{"+id+"},请联系管理员";
}else {
this.id = id;
this.msg = message;

View File

@ -12,6 +12,7 @@ import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.exception.ErrorTableException;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.globals.Global;
import com.ljsd.jieling.handler.GetPlayerInfoHandler;
@ -939,7 +940,7 @@ public class PlayerLogic {
}
Hero hero = userInMem.getHeroManager().getHero(heroId);
if(hero == null){
throw new ErrorCodeException(ErrorCode.newDefineCode("hero no"));
throw new ErrorTableException(159,"未找到英雄");
}
PlayerInfoProto.ViewHeroInfoResponse.Builder builder = PlayerInfoProto.ViewHeroInfoResponse.newBuilder();
Map<Integer, Long> heroNotBufferAttribute = HeroLogic.getInstance().calHeroNotBufferAttribute(userInMem, hero, true, teamId);

View File

@ -3,6 +3,7 @@ package config;
import manager.STableManager;
import manager.Table;
import java.util.HashMap;
import java.util.Map;
@Table(name ="ErrorCodeHint")
@ -11,11 +12,16 @@ public class SErrorCodeHint implements BaseConfig {
private int id;
private int showType;
private String desc;
public static Map<Integer, String> errorMap = new HashMap<>();
@Override
public void init() throws Exception {
Map<Integer, SErrorCodeHint> config = STableManager.getConfig(SErrorCodeHint.class);
for (SErrorCodeHint value : config.values()) {
errorMap.put(value.getId(),value.getDesc());
}
}
@ -27,5 +33,11 @@ public class SErrorCodeHint implements BaseConfig {
return showType;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}