using MxGateway.Contracts.Proto;
namespace MxGateway.Client;
///
/// Exception thrown when a gateway RPC call fails or returns an error status.
///
public class MxGatewayException : Exception
{
///
/// Initializes a new instance of the MxGatewayException class with the specified message.
///
/// Diagnostic message describing the failure.
public MxGatewayException(string message)
: base(message)
{
Statuses = [];
}
///
/// Initializes a new instance of the MxGatewayException class with the specified message and inner exception.
///
/// Diagnostic message describing the failure.
/// Underlying exception that caused this failure.
public MxGatewayException(string message, Exception? innerException)
: base(message, innerException)
{
Statuses = [];
}
///
/// Initializes a new instance of the MxGatewayException class with full diagnostic information.
///
/// Diagnostic message describing the failure.
/// Session ID associated with the exception, if available.
/// Correlation ID associated with the exception, if available.
/// Protocol-level status returned by the gateway, if available.
/// HRESULT code returned by the worker or MXAccess, if available.
/// List of MXAccess status codes returned by the operation.
/// Underlying exception that caused this failure.
public MxGatewayException(
string message,
string? sessionId,
string? correlationId,
ProtocolStatus? protocolStatus,
int? hResult,
IReadOnlyList statuses,
Exception? innerException = null)
: base(message, innerException)
{
SessionId = sessionId;
CorrelationId = correlationId;
ProtocolStatus = protocolStatus;
HResultCode = hResult;
Statuses = statuses;
}
///
/// Gets the session ID associated with the exception, if available.
///
public string? SessionId { get; }
///
/// Gets the correlation ID associated with the exception, if available.
///
public string? CorrelationId { get; }
///
/// Gets the protocol-level status returned by the gateway, if available.
///
public ProtocolStatus? ProtocolStatus { get; }
///
/// Gets the HRESULT code returned by the worker or MXAccess, if available.
///
public int? HResultCode { get; }
///
/// Gets the list of MXAccess status codes returned by the operation.
///
public IReadOnlyList Statuses { get; }
}