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

/// <summary>
/// Exception raised when communication with a worker process fails.
/// </summary>
public sealed class WorkerClientException : Exception
{
    /// <summary>
    /// Initializes with an error code and message.
    /// </summary>
    /// <param name="errorCode">Worker client error code classifying the failure.</param>
    /// <param name="message">Diagnostic message.</param>
    public WorkerClientException(
        WorkerClientErrorCode errorCode,
        string message)
        : base(message)
    {
        ErrorCode = errorCode;
    }

    /// <summary>
    /// Initializes with an error code, message, and inner exception.
    /// </summary>
    /// <param name="errorCode">Worker client error code classifying the failure.</param>
    /// <param name="message">Diagnostic message.</param>
    /// <param name="innerException">Underlying exception.</param>
    public WorkerClientException(
        WorkerClientErrorCode errorCode,
        string message,
        Exception innerException)
        : base(message, innerException)
    {
        ErrorCode = errorCode;
    }

    /// <summary>
    /// The worker client error code classifying the failure.
    /// </summary>
    public WorkerClientErrorCode ErrorCode { get; }
}
