INNER CODE UNIT · Python

resolve_error_code

LoD-Dawn/Fast-Vben-Admin · backend/app/main.py:113

def resolve_error_code(*, status_code: int, detail: str, path: str) -> str:
    """Keep ERP business failures distinguishable without changing legacy APIs."""

    mapped = ERROR_CODE_BY_MESSAGE.get(detail)
    if mapped is not None:
        return mapped
    if "/erp" not in path:
        return ERROR_CODE_BY_STATUS.get(status_code, "REQUEST_ERROR")
    if "Idempotency" in detail or "Idempotency-Key" in detail:
        return "ERP_IDEMPOTENCY_CONFLICT"
    if detail.endswith(" not found"):
        return "ERP_RESOURCE_NOT_FOUND"
    if " is inactive" in detail:
        return "ERP_MASTER_DATA_INACTIVE"
    if " is unavailable" in detail:
        return "ERP_MASTER_DATA_UNAVAILABLE"
    if "version conflict" in detail:
        return "ERP_DOCUMENT_VERSION_CONFLICT"

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…