All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sinszm.common.exception.ApiError Maven / Gradle / Ivy

Go to download

基于SpringBoot扩展生态应用公共组件 Copyright © 2020 智慧程序猿 All rights reserved. https://www.sinsz.com

There is a newer version: 1.1.3.RELEASE
Show newest version
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