com.sinszm.common.exception.ApiError Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of szm-boot-common Show documentation
Show all versions of szm-boot-common Show documentation
基于SpringBoot扩展生态应用公共组件
Copyright © 2020 智慧程序猿 All rights reserved.
https://www.sinsz.com
package com.sinszm.common.exception;
import org.springframework.util.StringUtils;
/**
* 错误代码通用接口
*
* @author chenjianbo
*/
public interface ApiError {
/**
* 错误代码
* @return 代码
*/
String getCode();
/**
* 错误消息
* @return 消息
*/
String getMessage();
/**
* 组装错误消息
* @return 错误代码信息
*/
default String message() {
String code = getCode();
if (StringUtils.isEmpty(code)) {
code = SystemApiError.SYSTEM_ERROR_02.name();
}
String message = getMessage();
if (StringUtils.isEmpty(message)) {
message = SystemApiError.SYSTEM_ERROR_02.getMessage();
}
return code.toUpperCase()
.replace("_", "-")
+ ":" + message;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy