-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8dcb14
commit fc361e6
Showing
4 changed files
with
113 additions
and
11 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
ChronAnt-type/src/main/java/cn/uhoc/type/enums/ExceptionCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package cn.uhoc.type.enums; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
/** | ||
* 错误状态和信息 | ||
*/ | ||
@Getter | ||
@AllArgsConstructor | ||
public enum ExceptionCode { | ||
|
||
// TODO 为每个响应码添加注释 | ||
// TODO 学习枚举enum | ||
|
||
/** | ||
* 成功 | ||
*/ | ||
SUCCESS(0, "ok"), | ||
ERR_INPUT_INVALID(8020, "input invalid"), | ||
// ERR_SHOULD_BIND(8021, "should bind failed"), | ||
// ERR_JSON_MARSHAL(8022, "json marshal failed"), | ||
ERR_GET_TASK_INFO(8035, "get task info failed"), | ||
// ERR_GET_TASK_HANDLE_PROCESS(8036, "get task handle process Failed"), | ||
ERR_CREATE_TASK(8037, "create task failed"), | ||
ERR_GET_TASK_LIST(8038, "get task list failed"), | ||
ERR_GET_TASK_CFG(8039, "get task config failed"), | ||
// ERR_INCREASE_CRT_RETRY_NUM(8040, "set task failed"), | ||
// ERR_SET_TASK(8041, "increase crt retry num failed"), | ||
/** | ||
* 获取任务位置失败 | ||
*/ | ||
ERR_GET_TASK_POS(8042, "get task position failed"), | ||
// ERR_GET_PROCESSING_COUNT(8043, "get processing count failed"), | ||
// ERR_SET_USER_PRIORITY(8045, "set user priority failed"), | ||
// ERR_GET_TASK_CFG_FROM_DB(8046, "get task cfg failed"), | ||
// ERR_SET_TASK_CFG_FROM_DB(8047, "set task cfg failed") | ||
; | ||
|
||
|
||
private final int code; | ||
private final String info; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package cn.uhoc.type.exception; | ||
|
||
import cn.uhoc.type.enums.ExceptionCode; | ||
import lombok.Data; | ||
|
||
/** | ||
* @program: ChronAnt | ||
* @description: | ||
* @author: chouchouGG | ||
* @create: 2024-12-01 15:48 | ||
**/ | ||
@Data | ||
public class E extends RuntimeException{ | ||
|
||
/** | ||
* 异常码 | ||
*/ | ||
private String code; | ||
|
||
/** 异常信息 */ | ||
private String info; | ||
|
||
public E(int code) { | ||
this.code = String.valueOf(code); | ||
} | ||
|
||
public E(int code, Throwable cause) { | ||
this.code = String.valueOf(code); | ||
super.initCause(cause); | ||
} | ||
|
||
public E(ExceptionCode r) { | ||
this(r.getCode(), r.getInfo()); | ||
} | ||
|
||
public E(int code, String info) { | ||
this.code = String.valueOf(code); | ||
this.info = info; | ||
} | ||
|
||
public E(int code, String info, Throwable cause) { | ||
this.code = String.valueOf(code); | ||
this.info = info; | ||
super.initCause(cause); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package cn.uhoc.type.model; | ||
|
||
import cn.uhoc.type.enums.ExceptionCode; | ||
import lombok.*; | ||
|
||
@Data | ||
@Builder | ||
@AllArgsConstructor | ||
public class R<T> { | ||
|
||
private int code; | ||
private String info; | ||
private T data; | ||
|
||
public R(ExceptionCode responseCode) { | ||
this.code = responseCode.getCode(); | ||
this.info = responseCode.getInfo(); | ||
} | ||
|
||
public R(T data) { | ||
this(ExceptionCode.SUCCESS); | ||
this.data = data; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.