Skip to content

Commit d1a17cc

Browse files
committed
Implement the new InvalidTypeException
The new `InvalidTypeException` is used to replace the legacy `TypeLoadException` (2d0047e). This ensures that callers can catch the general `TopicMappingException`, which this derives from, in order to catch these errors—whereas `TypeLoadException` derived from a different exception—while still allowing callers to catch this specific exception, if appropriate.
1 parent 2d0047e commit d1a17cc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

OnTopic/Mapping/TopicMappingService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public TopicMappingService(ITopicRepository topicRepository, ITypeLookupService
121121
var viewModelType = _typeLookupService.Lookup($"{topic.ContentType}TopicViewModel");
122122

123123
if (viewModelType is null || !viewModelType.Name.EndsWith("TopicViewModel", StringComparison.CurrentCultureIgnoreCase)) {
124-
throw new TypeLoadException(
124+
throw new InvalidTypeException(
125125
$"No class named '{topic.ContentType}TopicViewModel' could be located in any loaded assemblies. This is required " +
126126
$"to map the topic '{topic.GetUniqueKey()}'."
127127
);
@@ -755,7 +755,7 @@ MappedTopicCache cache
755755
try {
756756
topicDto = await MapAsync(source, configuration.CrawlRelationships, cache).ConfigureAwait(false);
757757
}
758-
catch (TypeLoadException) {
758+
catch (InvalidTypeException) {
759759
//Disregard errors caused by unmapped view models; those are functionally equivalent to IsAssignableFrom() mismatches
760760
}
761761
if (topicDto is not null && configuration.Property.PropertyType.IsAssignableFrom(topicDto.GetType())) {

0 commit comments

Comments
 (0)