Skip to content

Commit

Permalink
Throwing communicationException when it is connectionError (#6942)
Browse files Browse the repository at this point in the history
Multiple errors can happen when link/session is closing. Throw ServiceBusCommunicationException instead of ServiceBusException.

Fixes #6097
  • Loading branch information
nemakam authored Jul 16, 2019
1 parent 40cf7ce commit 58b0c96
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ public static Exception GetClientException(Exception exception, string reference
case OperationCanceledException operationCanceledException when operationCanceledException.InnerException is AmqpException amqpException:
return amqpException.Error.ToMessagingContractException(connectionError);

case OperationCanceledException _ when connectionError:
return new ServiceBusCommunicationException(message, aggregateException);

case OperationCanceledException _:
return new ServiceBusException(true, message, aggregateException);

Expand All @@ -216,6 +219,11 @@ public static Exception GetClientException(Exception exception, string reference
return new ServiceBusCommunicationException(message, aggregateException);
}

if (connectionError)
{
return new ServiceBusCommunicationException(message, aggregateException);
}

return aggregateException;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@ protected virtual async Task<IList<Message>> OnReceiveAsync(int maxMessageCount,
}
catch (Exception exception)
{
throw AmqpExceptionHelper.GetClientException(exception, receiveLink?.GetTrackingId(), null, receiveLink?.Session.IsClosing() ?? false);
throw AmqpExceptionHelper.GetClientException(exception, receiveLink?.GetTrackingId(), null, receiveLink?.IsClosing() ?? false);
}
}

Expand Down

0 comments on commit 58b0c96

Please sign in to comment.