Skip to content

Commit 1f49495

Browse files
committed
Updated ReverseTopicMappingService to use InvalidOperationException
Previously, several validators used the `InvalidEnumArgumentException`, which makes sense if validating the argument of e.g. an `Attribute`, but these particular validators aren't doing that. Fell back to the more general `InvalidOperationException`. As these are primarily intended to validate design decisions, they aren't expected to impact any implementations.
1 parent 4bf36ad commit 1f49495

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

OnTopic/Mapping/Reverse/ReverseTopicMappingService.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,17 @@ public ReverseTopicMappingService(ITopicRepository topicRepository) {
145145

146146
//Ensure the content type is valid
147147
if (!_contentTypeDescriptors.Contains(source.ContentType)) {
148-
throw new InvalidEnumArgumentException(
148+
throw new InvalidOperationException(
149149
$"The {nameof(source)} object (with the key '{source.Key}') has a content type of '{source.ContentType}'. There " +
150-
$"no matching content type in the ITopicRepository provided. This suggests that the binding model is invalid. If " +
151-
$"this is expected—e.g., if the content type is being added as part of this operation—then it needs to be added " +
150+
$"are no matching content types in the ITopicRepository provided. This suggests that the binding model is invalid. " +
151+
$"If this is expected—e.g., if the content type is being added as part of this operation—then it needs to be added " +
152152
$"to the same ITopicRepository instance prior to creating any instances of it."
153153
);
154154
}
155155

156156
//Ensure the content types match
157157
if (source.ContentType != target.ContentType) {
158-
throw new InvalidEnumArgumentException(
158+
throw new InvalidOperationException(
159159
$"The {nameof(source)} object (with the key '{source.Key}') has a content type of '{source.ContentType}', while " +
160160
$"the {nameof(target)} object (with the key '{source.Key}') has a content type of '{target.ContentType}'. It is not" +
161161
$"permitted to change the topic's content type during a mapping operation, as this interferes with the validation. " +
@@ -165,7 +165,7 @@ public ReverseTopicMappingService(ITopicRepository topicRepository) {
165165

166166
//Ensure the keys match
167167
if (source.Key != target.Key && !String.IsNullOrEmpty(source.Key)) {
168-
throw new InvalidEnumArgumentException(
168+
throw new InvalidOperationException(
169169
$"The {nameof(source)} object has a key of '{source.Key}', while the {nameof(target)} object has a key of " +
170170
$"'{target.Key}'. It is not permitted to change the topic'key during a mapping operation, as this suggests in " +
171171
$"invalid target. If this is by design, change the key on the target topic prior to invoking MapAsync()."

0 commit comments

Comments
 (0)