springboot异常处理的通用方式2

2、定义一个异常的枚举数组

  • ServerErrCodeDefine类

//```java
@AllArgsConstructor
@Getter
public enum ServerErrCodeDefine {

private int errCode;
private String code;
private HttpStatus httpStatus;
private String messageSourceKey;


/*********************************************
 * 启动错误 从5000开始
 *********************************************/
SystemLoginEncryptNotEmpty(5000, "EncryptNotEmpty", HttpStatus.INTERNAL_SERVER_ERROR, "system.login.encrypt.empty"), fmuSystemLoginTokenNotEmpty(5001, "TokenNotEmpty", HttpStatus.INTERNAL_SERVER_ERROR, "system.login.token.empty"),

/*********************************************
 * 认证操作异常码 从6000开始
 *********************************************/
SecurityHeaderAuthorNotEmpty(6000, "AuthorNotEmpty", HttpStatus.UNAUTHORIZED, "security.header.author.empty"), fmuSecurityHeaderDateNotEmpty(6001, "DateNotEmpty", HttpStatus.BAD_REQUEST, "security.header.date.empty"), fmuSecurityInvalidHeaderValue(6002, "InvalidHeaderField", HttpStatus.UNAUTHORIZED, "security.header.value.invalid"), fmuSecurityInvalidAlgorithm(6003, "InvalidAlgorithmType", HttpStatus.BAD_REQUEST, "security.header.algorithm.invalid"), fmuSecurityInvalidUser(6004, "InvalidAccessKey", HttpStatus.FORBIDDEN, "security.header.user.invalid"), fmuSecurityTimeTooSkewed(6005, "TimeTooSkewed", HttpStatus.REQUEST_TIMEOUT, "security.request.timetooskewed"), fmuSecurityUnsupportedEncoding(6006, "UnsupportedEncoding", HttpStatus.UNAUTHORIZED, "security.unsupported.encoding"), fmuSecurityUnsupportedAlgorithm(6007, "UnsupportedAlgorithm", HttpStatus.UNAUTHORIZED, "security.unsupported.algorithm"), fmuSecurityUnauthorized(6008, "Unauthorized", HttpStatus.UNAUTHORIZED, "security.unauthorized"), fmuSecurityContentTypeNotEmpty(6009, "ContentTypeNotEmpty", HttpStatus.UNAUTHORIZED, "security.header.contenttype.empty"), fmuSystemNoVisitPriviledge(6010, "NoVisitPriviledge", HttpStatus.NOT_ACCEPTABLE, "system.no.visit.priviledge"), fmuSystemSubscribeCostomSendFailed(6011, "VslServerFailed", HttpStatus.SERVICE_UNAVAILABLE, "request.to.vsl.server.failed"), fmuSystemVslReturnDataErr(6012, "VslReturnDataErr", HttpStatus.SERVICE_UNAVAILABLE, "system.vsl.return.data.error"),

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Fire Fish

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值