Skip to content

Commit

Permalink
Removed exception types from EventPublishedContext and done with work…
Browse files Browse the repository at this point in the history
… of EventPublisherListener work.
  • Loading branch information
ShreyasJejurkar committed Oct 10, 2020
1 parent c745a6b commit 6712693
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 21 deletions.
22 changes: 6 additions & 16 deletions src/Eventify/EventPublishedContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,18 @@ public class EventPublishedContext : EventPublishingContext
/// <summary>
/// Represents the does exception occurred while publishing event or not
/// </summary>
public bool IsFaulted => EventExceptionList.Count != 0;
public bool IsFaulted => EventException != null;

/// <summary>
/// This will contain occurred exception information for further logging or processing
/// </summary>
public List<Exception> EventExceptionList { get; }

/// <summary>
/// Type of handler in which <see cref="Exception"/> has been thrown-ed
/// </summary>
public List<Type> ExceptionHandlerTypeList { get; }
public Exception EventException { get; private set; }

internal EventPublishedContext(Guid eventId, string eventName, Type eventType) : base(eventId, eventName, eventType)
internal EventPublishedContext(Guid eventId, string eventName, Type eventType)
: base(eventId, eventName, eventType)
{
EventExceptionList = new List<Exception>();
ExceptionHandlerTypeList = new List<Type>();
}

internal void SetException(Exception e, Type handlerExceptionType)
internal void SetException(Exception e)
{
EventExceptionList.Add(e);
ExceptionHandlerTypeList.Add(handlerExceptionType);
EventException = e;
}
}
}
2 changes: 1 addition & 1 deletion src/Eventify/EventPublishingContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Eventify
/// </summary>
public class EventPublishingContext
{
protected object _eventData;
private object _eventData;

/// <summary>
/// Id of currently published <see cref="Event"/>
Expand Down
2 changes: 1 addition & 1 deletion src/Eventify/Eventify.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.8" />
</ItemGroup>

</Project>
4 changes: 3 additions & 1 deletion src/Eventify/EventifyServiceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public static void AddEventify(this IServiceCollection services, params Assembly

foreach (var assembly in assemblies)
{
var classTypes = assembly.GetTypes().Select(t => t.GetTypeInfo()).Where(t => t.IsClass && !t.IsAbstract);
var classTypes = assembly.GetTypes().Select(t => t.GetTypeInfo())
.Where(t => t.IsClass && !t.IsAbstract);

foreach (var type in classTypes)
{
Expand All @@ -29,6 +30,7 @@ public static void AddEventify(this IServiceCollection services, params Assembly
}
}
}

services.AddScoped<IEventPublisher, InMemoryEventPublisher>();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Eventify/IEventPublisherListener.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Eventify
{
/// <summary>
/// Contract for Event listeners
/// Contract for Event publisher listeners
/// </summary>
public interface IEventPublisherListener
{
Expand Down
2 changes: 1 addition & 1 deletion src/Eventify/InMemoryEventPublisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public Task Publish(Event @event)
}
catch (Exception e)
{
publishedContext.SetException(e, handler.GetType());
publishedContext.SetException(e);
publishedContext.SetEventData(eventPublishingContext.GetEventData());
}
}
Expand Down

0 comments on commit 6712693

Please sign in to comment.