diff --git a/JustSaying/JustSayingFluently.cs b/JustSaying/JustSayingFluently.cs index d822627d6..c4519e3be 100644 --- a/JustSaying/JustSayingFluently.cs +++ b/JustSaying/JustSayingFluently.cs @@ -6,11 +6,11 @@ using JustSaying.AwsTools.MessageHandling; using JustSaying.AwsTools.QueueCreation; using JustSaying.Extensions; +using JustSaying.Messaging.Interrogation; using JustSaying.Messaging.MessageHandling; using JustSaying.Messaging.MessageSerialisation; using JustSaying.Messaging.Monitoring; using JustSaying.Models; -using JustSaying.Messaging.Interrogation; using Microsoft.Extensions.Logging; namespace JustSaying @@ -232,6 +232,16 @@ public IFluentSubscription IntoQueue(string queuename) /// public IHaveFulfilledSubscriptionRequirements WithMessageHandler(IHandlerAsync handler) where T : Message { + if (handler == null) + { + throw new ArgumentNullException(nameof(handler)); + } + + if (_serialisationFactory == null) + { + throw new InvalidOperationException($"No {nameof(IMessageSerialisationFactory)} has been configured."); + } + // TODO - Subscription listeners should be just added once per queue, // and not for each message handler var thing = _subscriptionConfig.SubscriptionType == SubscriptionType.PointToPoint @@ -250,6 +260,11 @@ public IHaveFulfilledSubscriptionRequirements WithMessageHandler(IHandlerAsyn public IHaveFulfilledSubscriptionRequirements WithMessageHandler(IHandlerResolver handlerResolver) where T : Message { + if (_serialisationFactory == null) + { + throw new InvalidOperationException($"No {nameof(IMessageSerialisationFactory)} has been configured."); + } + var thing = _subscriptionConfig.SubscriptionType == SubscriptionType.PointToPoint ? PointToPointHandler() : TopicHandler(); diff --git a/JustSaying/JustSayingFluentlyExtensions.cs b/JustSaying/JustSayingFluentlyExtensions.cs index 25bf79fd4..5c9d69652 100644 --- a/JustSaying/JustSayingFluentlyExtensions.cs +++ b/JustSaying/JustSayingFluentlyExtensions.cs @@ -66,9 +66,14 @@ public static IFluentSubscription IntoDefaultQueue(this ISubscriberIntoQueue sub public static IHaveFulfilledSubscriptionRequirements WithMessageHandlers( this IFluentSubscription sub, params IHandlerAsync[] handlers) where T : Message { + if (handlers == null) + { + throw new ArgumentNullException(nameof(handlers)); + } + if (handlers.Length == 0) { - throw new ArgumentException("No handlers in list"); + throw new ArgumentException("No message handlers specified.", nameof(handlers)); } if (handlers.Length == 1)