package de.effigenix.domain.masterdata.productcategory;

public sealed interface ProductCategoryError {

    String code();
    String message();

    record CategoryNotFound(ProductCategoryId id) implements ProductCategoryError {
        @Override public String code() { return "CATEGORY_NOT_FOUND"; }
        @Override public String message() { return "ProductCategory with ID '" + id.value() + "' not found"; }
    }

    record CategoryNameAlreadyExists(String name) implements ProductCategoryError {
        @Override public String code() { return "CATEGORY_NAME_EXISTS"; }
        @Override public String message() { return "Category name '" + name + "' already exists"; }
    }

    record CategoryInUse(ProductCategoryId id) implements ProductCategoryError {
        @Override public String code() { return "CATEGORY_IN_USE"; }
        @Override public String message() { return "Category '" + id.value() + "' is still assigned to articles"; }
    }

    record InvalidCategoryName(String reason) implements ProductCategoryError {
        @Override public String code() { return "CATEGORY_INVALID_NAME"; }
        @Override public String message() { return "Invalid category name: " + reason; }
    }

    record ValidationFailure(String message) implements ProductCategoryError {
        @Override public String code() { return "VALIDATION_ERROR"; }
    }

    record Unauthorized(String message) implements ProductCategoryError {
        @Override public String code() { return "UNAUTHORIZED"; }
    }

    record RepositoryFailure(String message) implements ProductCategoryError {
        @Override public String code() { return "REPOSITORY_ERROR"; }
    }
}
