31e16fbc80
- keepalive: 30 s ping / 10 s timeout / Always, configurable via KeepAlivePingDelay/Timeout (CDN-004, D7) - GrpcStatusMapper shared by both transports: server Cancelled with a live token is no longer OperationCanceledException; NotFound/FailedPrecondition on session RPCs -> MxGatewaySessionException; MxGatewayException.GrpcStatusCode preserves the status (CDN-001, CDN-002) - Register/AddItem/AddItem2 raise MxGatewayMalformedReplyException on a payload-less reply (CDN-008) - MxGatewayEventStream.DisposeAsync waits for the in-flight read (CDN-003); session DisposeAsync is bounded to 5 s and swallows cancellation (CDN-005); owned handler + pinned CA disposed (CDN-006) - ResourceExhausted no longer retried (CDN-007) - CLI: batch reuses clients, stream/bench commands exempt from the 30 s timeout, OCE reported as an error with exit 1, --value redacted only for write-secured* and only as a whole token, bench backs off on failures (CDN-009, CDN-010, CDN-011)
90 lines
3.5 KiB
C#
90 lines
3.5 KiB
C#
using ZB.MOM.WW.MxGateway.Contracts.Proto;
|
|
|
|
namespace ZB.MOM.WW.MxGateway.Client;
|
|
|
|
/// <summary>
|
|
/// Exception thrown when a gateway RPC call fails or returns an error status.
|
|
/// </summary>
|
|
public class MxGatewayException : Exception
|
|
{
|
|
/// <summary>
|
|
/// Initializes a new instance of the MxGatewayException class with the specified message.
|
|
/// </summary>
|
|
/// <param name="message">Diagnostic message describing the failure.</param>
|
|
public MxGatewayException(string message)
|
|
: base(message)
|
|
{
|
|
Statuses = [];
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the MxGatewayException class with the specified message and inner exception.
|
|
/// </summary>
|
|
/// <param name="message">Diagnostic message describing the failure.</param>
|
|
/// <param name="innerException">Underlying exception that caused this failure.</param>
|
|
public MxGatewayException(string message, Exception? innerException)
|
|
: base(message, innerException)
|
|
{
|
|
Statuses = [];
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the MxGatewayException class with full diagnostic information.
|
|
/// </summary>
|
|
/// <param name="message">Diagnostic message describing the failure.</param>
|
|
/// <param name="sessionId">Session ID associated with the exception, if available.</param>
|
|
/// <param name="correlationId">Correlation ID associated with the exception, if available.</param>
|
|
/// <param name="protocolStatus">Protocol-level status returned by the gateway, if available.</param>
|
|
/// <param name="hResult">HRESULT code returned by the worker or MXAccess, if available.</param>
|
|
/// <param name="statuses">List of MXAccess status codes returned by the operation.</param>
|
|
/// <param name="innerException">Underlying exception that caused this failure.</param>
|
|
public MxGatewayException(
|
|
string message,
|
|
string? sessionId,
|
|
string? correlationId,
|
|
ProtocolStatus? protocolStatus,
|
|
int? hResult,
|
|
IReadOnlyList<MxStatusProxy> statuses,
|
|
Exception? innerException = null)
|
|
: base(message, innerException)
|
|
{
|
|
SessionId = sessionId;
|
|
CorrelationId = correlationId;
|
|
ProtocolStatus = protocolStatus;
|
|
HResultCode = hResult;
|
|
Statuses = statuses;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the gRPC status code of the failed call when this exception wraps an
|
|
/// <see cref="Grpc.Core.RpcException"/>, otherwise <see langword="null"/>. Lets a caller tell
|
|
/// "deadline exceeded" from "gateway unavailable" without digging into the inner exception.
|
|
/// </summary>
|
|
public Grpc.Core.StatusCode? GrpcStatusCode => (InnerException as Grpc.Core.RpcException)?.StatusCode;
|
|
|
|
/// <summary>
|
|
/// Gets the session ID associated with the exception, if available.
|
|
/// </summary>
|
|
public string? SessionId { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the correlation ID associated with the exception, if available.
|
|
/// </summary>
|
|
public string? CorrelationId { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the protocol-level status returned by the gateway, if available.
|
|
/// </summary>
|
|
public ProtocolStatus? ProtocolStatus { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the HRESULT code returned by the worker or MXAccess, if available.
|
|
/// </summary>
|
|
public int? HResultCode { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the list of MXAccess status codes returned by the operation.
|
|
/// </summary>
|
|
public IReadOnlyList<MxStatusProxy> Statuses { get; }
|
|
}
|