package de.effigenix.domain.masterdata.supplier;

public sealed interface SupplierError {

    String code();
    String message();

    record SupplierNotFound(SupplierId id) implements SupplierError {
        @Override public String code() { return "SUPPLIER_NOT_FOUND"; }
        @Override public String message() { return "Supplier with ID '" + id.value() + "' not found"; }
    }

    record SupplierNameAlreadyExists(String name) implements SupplierError {
        @Override public String code() { return "SUPPLIER_NAME_EXISTS"; }
        @Override public String message() { return "Supplier name '" + name + "' already exists"; }
    }

    record InvalidRating(String reason) implements SupplierError {
        @Override public String code() { return "INVALID_RATING"; }
        @Override public String message() { return "Invalid rating: " + reason; }
    }

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

    record CertificateNotFound(String certificateType) implements SupplierError {
        @Override public String code() { return "CERTIFICATE_NOT_FOUND"; }
        @Override public String message() { return "Certificate of type '" + certificateType + "' not found"; }
    }

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

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