Exemplo n.º 1
0
        public static AmqpException GetAmqpException(Exception ex)
        {
            // If this exception is an AmqpException with LinkRedirect or NotAllowed errors, return it.
            if (ex is AmqpException amqpException)
            {
                if (amqpException.Error.Condition.Equals(AmqpErrorCode.LinkRedirect) || amqpException.Error.Condition.Equals(AmqpErrorCode.NotAllowed))
                {
                    return(amqpException);
                }
            }

            // Convert exception to EdgeHubAmqpException
            // TODO: Make sure EdgeHubAmqpException is thrown from the right places.
            EdgeHubAmqpException edgeHubAmqpException = GetEdgeHubAmqpException(ex);
            Error amqpError = GenerateAmqpError(edgeHubAmqpException);

            return(new AmqpException(amqpError));
        }
Exemplo n.º 2
0
 static Error GenerateAmqpError(EdgeHubAmqpException exception) => new Error
 {
     Description = JsonConvert.SerializeObject(exception.Message),
     Condition   = AmqpErrorMapper.GetErrorCondition(exception.ErrorCode),
     Info        = new Fields()
 };