exception/ErrorCode.java

ecommerce-microservices · common-lib/common-core/src/main/java/com/ecommerce/commonlib/exception/ErrorCode.java · java · MIT
payments

ErrorCode.java from hoangtien2k3/ecommerce-microservices

// Source: https://github.com/hoangtien2k3/ecommerce-microservices | License: MIT | Copyright 2026 Hoàng Anh Tiến
// Provided via justclaw.it.com; keep this notice with the code.
package com.ecommerce.commonlib.exception;

import lombok.Getter;
import org.springframework.http.HttpStatus;

/**
 * Centralized error catalog. Each entry is the contract between services and clients:
 * a stable machine-readable {@code code}, an i18n message key, and the HTTP status to return.
 *
 * <p>Why an enum: gives compile-time exhaustiveness checks at every {@code switch} site
 * and prevents typos in {@code code} / {@code messageKey} drift.</p>
 */
@Getter
public enum ErrorCode {

    // ---- Generic ----
    BAD_REQUEST("ERR-0400", "error.bad.request", HttpStatus.BAD_REQUEST),
    UNAUTHORIZED("ERR-0401

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key