mirror of
https://github.com/Melledy/Nebula.git
synced 2026-11-04 21:36:51 +01:00
Refactor error codes
This commit is contained in:
1 parent
6eadc42b27
commit
50f9995785
7 files changed
+59
-28
No files matched your search
@@ -4,7 +4,7 @@ import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.CharGemGenerate.CharGemGenerateReq;
|
||||
import emu.nebula.proto.CharGemGenerate.CharGemGenerateResp;
|
||||
import emu.nebula.server.error.ServerException;
|
||||
import emu.nebula.server.error.NebulaException;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.game.character.CharacterGem;
|
||||
import emu.nebula.game.player.PlayerChangeInfo;
|
||||
@@ -29,7 +29,7 @@ public class HandlerCharGemGenerateReq extends NetHandler {
|
||||
|
||||
try {
|
||||
change = character.generateGem(req.getSlotId());
|
||||
} catch (ServerException e) {
|
||||
} catch (NebulaException e) {
|
||||
return session.encodeMsg(NetMsgId.char_gem_generate_failed_ack, e.toProto());
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.CharGemRefresh.CharGemRefreshReq;
|
||||
import emu.nebula.proto.CharGemRefresh.CharGemRefreshResp;
|
||||
import emu.nebula.server.error.ServerException;
|
||||
import emu.nebula.server.error.NebulaException;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.game.character.CharacterGem;
|
||||
import emu.nebula.game.player.PlayerChangeInfo;
|
||||
@@ -30,7 +30,7 @@ public class HandlerCharGemRefreshReq extends NetHandler {
|
||||
|
||||
try {
|
||||
change = character.refreshGem(req.getSlotId(), req.getGemIndex(), req.getLockAttrs());
|
||||
} catch (ServerException e) {
|
||||
} catch (NebulaException e) {
|
||||
return session.encodeMsg(NetMsgId.char_gem_refresh_failed_ack, e.toProto());
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package emu.nebula.server.handlers;
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.ScoreBossApply.ScoreBossApplyReq;
|
||||
import emu.nebula.server.error.NebulaException;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@@ -15,10 +16,14 @@ public class HandlerScoreBossApplyReq extends NetHandler {
|
||||
var req = ScoreBossApplyReq.parseFrom(message);
|
||||
|
||||
// Apply
|
||||
boolean success = session.getPlayer().getScoreBossManager().apply(req.getLevelId(), req.getBuildId());
|
||||
try {
|
||||
session.getPlayer().getScoreBossManager().apply(req.getLevelId(), req.getBuildId());
|
||||
} catch (NebulaException e) {
|
||||
return session.encodeMsg(NetMsgId.score_boss_apply_failed_ack, e.toProto());
|
||||
}
|
||||
|
||||
// Encode and send
|
||||
return session.encodeMsg(success ? NetMsgId.score_boss_apply_succeed_ack : NetMsgId.score_boss_apply_failed_ack);
|
||||
return session.encodeMsg(NetMsgId.score_boss_apply_succeed_ack);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user