Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Null Reference Exceptions #455

Merged
merged 3 commits into from
Nov 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion JustSaying/JustSayingFluently.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -232,6 +232,16 @@ public IFluentSubscription IntoQueue(string queuename)
/// <returns></returns>
public IHaveFulfilledSubscriptionRequirements WithMessageHandler<T>(IHandlerAsync<T> 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
Expand All @@ -250,6 +260,11 @@ public IHaveFulfilledSubscriptionRequirements WithMessageHandler<T>(IHandlerAsyn

public IHaveFulfilledSubscriptionRequirements WithMessageHandler<T>(IHandlerResolver handlerResolver) where T : Message
{
if (_serialisationFactory == null)
{
throw new InvalidOperationException($"No {nameof(IMessageSerialisationFactory)} has been configured.");
}

var thing = _subscriptionConfig.SubscriptionType == SubscriptionType.PointToPoint
? PointToPointHandler<T>()
: TopicHandler<T>();
Expand Down
7 changes: 6 additions & 1 deletion JustSaying/JustSayingFluentlyExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,14 @@ public static IFluentSubscription IntoDefaultQueue(this ISubscriberIntoQueue sub
public static IHaveFulfilledSubscriptionRequirements WithMessageHandlers<T>(
this IFluentSubscription sub, params IHandlerAsync<T>[] 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)
Expand Down