package com.zb.mom.ww.mxgateway.client;

import mxaccess_gateway.v1.MxaccessGateway.MxCommandReply;
import mxaccess_gateway.v1.MxaccessGateway.ProtocolStatus;

/**
 * Thrown when the worker reports an MXAccess COM-side failure. Distinguishes
 * MXAccess errors (non-zero {@code HResult} or unsuccessful {@code MxStatusProxy})
 * from other gateway protocol failures.
 */
public final class MxAccessException extends MxGatewayCommandException {
    /**
     * Creates a new MXAccess exception with an explicit protocol status.
     *
     * @param operation human-readable name of the failing operation
     * @param protocolStatus protocol status reported by the gateway
     * @param reply raw command reply containing the MXAccess failure detail
     */
    public MxAccessException(String operation, ProtocolStatus protocolStatus, MxCommandReply reply) {
        super(operation, protocolStatus, reply);
    }

    /**
     * Creates a new MXAccess exception derived from a command reply.
     *
     * @param operation human-readable name of the failing operation
     * @param reply raw command reply; the protocol status is taken from this reply when present
     */
    public MxAccessException(String operation, MxCommandReply reply) {
        super(operation, reply == null ? null : reply.getProtocolStatus(), reply);
    }

    /**
     * Creates a new MXAccess exception with an already-built, verbatim message.
     * Used to re-surface an MXAccess failure with a redacted message while
     * preserving the original protocol status and reply.
     *
     * @param message the exact message to surface (already formatted/redacted)
     * @param protocolStatus protocol status reported by the gateway
     * @param reply raw command reply containing the MXAccess failure detail
     * @param cause underlying error, or {@code null}
     */
    public MxAccessException(String message, ProtocolStatus protocolStatus, MxCommandReply reply, Throwable cause) {
        super(message, protocolStatus, reply, cause);
    }
}
