namespace ZB.MOM.WW.MxGateway.Server.Workers;

/// <summary>
/// Exception thrown when a worker frame protocol violation occurs.
/// </summary>
public sealed class WorkerFrameProtocolException : Exception
{
    /// <summary>
    /// Initializes a frame protocol exception with an error code and message.
    /// </summary>
    /// <param name="errorCode">Protocol error code indicating the violation type.</param>
    /// <param name="message">Human-readable error message.</param>
    public WorkerFrameProtocolException(
        WorkerFrameProtocolErrorCode errorCode,
        string message)
        : base(message)
    {
        ErrorCode = errorCode;
    }

    /// <summary>
    /// Initializes a frame protocol exception with an error code, message, and inner exception.
    /// </summary>
    /// <param name="errorCode">Protocol error code indicating the violation type.</param>
    /// <param name="message">Human-readable error message.</param>
    /// <param name="innerException">Underlying exception that caused this protocol violation.</param>
    public WorkerFrameProtocolException(
        WorkerFrameProtocolErrorCode errorCode,
        string message,
        Exception innerException)
        : base(message, innerException)
    {
        ErrorCode = errorCode;
    }

    /// <summary>
    /// Gets the worker frame protocol error code.
    /// </summary>
    public WorkerFrameProtocolErrorCode ErrorCode { get; }
}
