public static PublishingTopic From(string topicAsString) { if (TopicNotValid(topicAsString)) { throw new InvalidTopicException(topicAsString); } var levels = Levels.From(topicAsString); if (AnyLevelNotValid(levels)) { throw new InvalidTopicException(topicAsString); //note: I'd rather throw more specific exception in this case, e.g. InvalidLevelException } return(new PublishingTopic(levels)); }
public static SubscriptionTopic From(string topicAsString) { if (TopicNotValid(topicAsString)) { throw new InvalidTopicException(topicAsString); } var levels = Levels.From(topicAsString); if (AnyLevelNotValid(levels)) { throw new InvalidTopicException(topicAsString); //note: I'd rather throw more specific exception in this case, e.g. InvalidLevelException, but don't want to change the initial tests } return(new SubscriptionTopic(levels)); }