using System;

namespace ZB.MOM.WW.MxGateway.Worker.Ipc;

/// <summary>
/// Exception raised when the named-pipe frame protocol encounters an error.
/// </summary>
public sealed class WorkerFrameProtocolException : Exception
{
    /// <summary>
    /// Initializes with an error code and message.
    /// </summary>
    /// <param name="errorCode">Protocol error classification.</param>
    /// <param name="message">Exception message.</param>
    public WorkerFrameProtocolException(
        WorkerFrameProtocolErrorCode errorCode,
        string message)
        : base(message)
    {
        ErrorCode = errorCode;
    }

    /// <summary>
    /// Initializes with an error code, message, and inner exception.
    /// </summary>
    /// <param name="errorCode">Protocol error classification.</param>
    /// <param name="message">Exception message.</param>
    /// <param name="innerException">Underlying cause.</param>
    public WorkerFrameProtocolException(
        WorkerFrameProtocolErrorCode errorCode,
        string message,
        Exception innerException)
        : base(message, innerException)
    {
        ErrorCode = errorCode;
    }

    /// <summary>
    /// The protocol error code classifying the failure.
    /// </summary>
    public WorkerFrameProtocolErrorCode ErrorCode { get; }
}
