Skip to content

Commit

Permalink
exception handling part5
Browse files Browse the repository at this point in the history
  • Loading branch information
Pil0tXia committed Oct 19, 2023
1 parent 1c7b131 commit 1efb961
Showing 1 changed file with 27 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,51 @@
@Getter
public enum Errors {

SUCCESS(HttpStatus.OK, "SUCCESS", "success"),
SUCCESS(HttpStatus.OK, Types.SUCCESS, "success"),

NACOS_SDK_CONFIG_ERR(HttpStatus.INTERNAL_SERVER_ERROR, "SDK_CONFIG_ERR",
NACOS_SDK_CONFIG_ERR(HttpStatus.INTERNAL_SERVER_ERROR, Types.SDK_CONFIG_ERR,
"Failed to create Nacos ConfigService. Please check EventMeshAdmin application configuration."),

NACOS_GET_CONFIGS_ERR(HttpStatus.BAD_GATEWAY, "META_COM_ERR", "Failed to retrieve Nacos config(s)."),
NACOS_GET_CONFIGS_ERR(HttpStatus.BAD_GATEWAY, Types.META_COM_ERR, "Failed to retrieve Nacos config(s)."),

NACOS_EMPTY_RESP_ERR(HttpStatus.BAD_GATEWAY, "META_COM_ERR", "No result returned by Nacos. Please check Nacos."),
NACOS_EMPTY_RESP_ERR(HttpStatus.BAD_GATEWAY, Types.META_COM_ERR, "No result returned by Nacos. Please check Nacos."),

NACOS_LOGIN_ERR(HttpStatus.UNAUTHORIZED, "META_COM_ERR", "Nacos login failed."),
NACOS_LOGIN_ERR(HttpStatus.UNAUTHORIZED, Types.META_COM_ERR, "Nacos login failed."),

NACOS_LOGIN_EMPTY_RESP_ERR(HttpStatus.BAD_GATEWAY, "META_COM_ERR", "Nacos didn't return accessToken. Please check Nacos status."),
NACOS_LOGIN_EMPTY_RESP_ERR(HttpStatus.BAD_GATEWAY, Types.META_COM_ERR, "Nacos didn't return accessToken. Please check Nacos status."),
;

// error code
private final HttpStatus code;

// error type
private final String type;
private final Types type;

// error message
private final String desc;

Errors(HttpStatus code, String type, String desc) {
Errors(HttpStatus code, Types type, String desc) {
this.code = code;
this.type = type;
this.desc = desc;
}

public enum Types {

SUCCESS("Operation Success"),

SDK_CONFIG_ERR("The Meta SDK config in EventMeshAdmin application.yml error"),

META_COM_ERR("Network communication to Meta error"),
;

/**
* Helpful for understanding and not used for now
*/
private final String desc;

Types(String desc) {
this.desc = desc;
}
}
}

0 comments on commit 1efb961

Please sign in to comment.