Editor
how to use the error design panel of ApiHug Api design Copilot.
Go through the Error design and view of ApiHug Api design Copilot
Please refer: apihug-full-demo error.proto
enum UserErrorsEnum {
option (hope.swagger.enm) = {
description: "User account management errors";
};
USER_EXIST = 0 [
(hope.constant.field) = {
code: 1001023, message: "customer already exist", message2: "用户存在",
error: {
tips: "contact your admin",
phase: DOMAIN,
severity: FATAL,
}}];
}
Please refer: apihug-full-demo UserErrorsEnum.java
@ProtoFrom(
value = "com/apihug/demo/user/proto/infra/settings/admin/error.proto",
entity = "UserErrorsEnum",
kind = Kind.ENUM
)
public enum UserErrorsEnum implements Errors {
INSTANCE;
public static final List<Error> ERRORS = new ArrayList();
public static final Map<String, Error> ERRORS_MAP;
public static final Error UNDEFINED = Error.unknown().setDomain("user").setTitle("UNDEFINED");
public static final Error USER_EXIST = new Error();
public static final Error USER_BLOCKED = new Error();
static {
Map<String, Error> _ERRORS_MAP = new LinkedHashMap<>();
USER_EXIST.setDomain("user");
USER_EXIST.setCode(1001023);
USER_EXIST.setDescription("customer already exist");
USER_EXIST.setDescription2("用户存在");
USER_EXIST.setTitle("USER_EXIST");
USER_EXIST.setTips("contact your admin");
USER_EXIST.setPhase(Phase.DOMAIN);
USER_EXIST.setSeverity(Severity.FATAL);
_ERRORS_MAP.put("USER_EXIST", USER_EXIST);
//...
}
}