Skip to content

Commit 80892d9

Browse files
authored
Merge pull request #85 from Particular/exceptions
Added different exception types
2 parents 0fead41 + f8418c0 commit 80892d9

File tree

7 files changed

+43
-7
lines changed

7 files changed

+43
-7
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace Billing
2+
{
3+
using System;
4+
5+
public class BillingProcessingException : Exception
6+
{
7+
public BillingProcessingException(string message) : base(message)
8+
{
9+
}
10+
}
11+
}

src/Billing/SimulationEffects.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
namespace Billing;
2-
32
using MassTransit;
43
using Messages;
54
using Microsoft.AspNetCore.SignalR;
@@ -29,7 +28,7 @@ public async Task SimulateBillingProcessing(ConsumeContext<OrderPlaced> context)
2928
&& (!isRetry || ShouldFailRetries))
3029
{
3130
Interlocked.Increment(ref messagesErrored);
32-
throw new Exception($"A simulated failure occurred in Billing, OrderId: {context.Message.OrderId}, Contents: {string.Join(", ", context.Message.Contents)}");
31+
throw new BillingProcessingException($"A simulated failure occurred in Billing, OrderId: {context.Message.OrderId}, Contents: {string.Join(", ", context.Message.Contents)}");
3332
}
3433

3534
Interlocked.Increment(ref messagesProcessed);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace Sales
2+
{
3+
4+
public class SalesProcessingException : Exception
5+
{
6+
public SalesProcessingException(string message) : base(message)
7+
{
8+
}
9+
}
10+
}

src/Sales/SimulationEffects.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
namespace Sales;
2-
32
using MassTransit;
43
using Messages;
54
using Microsoft.AspNetCore.SignalR;
@@ -29,7 +28,7 @@ public async Task SimulateSalesProcessing(ConsumeContext<PlaceOrder> context)
2928
&& (!isRetry || ShouldFailRetries))
3029
{
3130
Interlocked.Increment(ref messagesErrored);
32-
throw new Exception($"A simulated failure occurred in Sales, OrderId: {context.Message.OrderId}, Contents: {string.Join(", ", context.Message.Contents)}");
31+
throw new SalesProcessingException($"A simulated failure occurred in Sales, OrderId: {context.Message.OrderId}, Contents: {string.Join(", ", context.Message.Contents)}");
3332
}
3433

3534
Interlocked.Increment(ref messagesProcessed);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Shipping
2+
{
3+
public class OrderBilledException : Exception
4+
{
5+
public OrderBilledException(string message) : base(message)
6+
{
7+
}
8+
}
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Shipping
2+
{
3+
public class OrderPlacedException : Exception
4+
{
5+
public OrderPlacedException(string message) : base(message)
6+
{
7+
}
8+
}
9+
}

src/Shipping/SimulationEffects.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
namespace Shipping;
2-
32
using MassTransit;
43
using Messages;
54
using Microsoft.AspNetCore.SignalR;
@@ -33,7 +32,7 @@ public async Task SimulateOrderBilledProcessing(ConsumeContext<OrderBilled> cont
3332
&& (!isRetry || ShouldFailRetries))
3433
{
3534
Interlocked.Increment(ref orderBilledErrored);
36-
throw new Exception($"A simulated failure occurred in Shipping Order Billed handling, OrderId: {context.Message.OrderId}, Contents: {string.Join(", ", context.Message.Contents)}");
35+
throw new OrderBilledException($"A simulated failure occurred in Shipping Order Billed handling, OrderId: {context.Message.OrderId}, Contents: {string.Join(", ", context.Message.Contents)}");
3736
}
3837

3938
Interlocked.Increment(ref orderBilledProcessed);
@@ -59,7 +58,7 @@ public async Task SimulateOrderPlacedProcessing(ConsumeContext<OrderPlaced> cont
5958
&& (!isRetry || ShouldFailRetries))
6059
{
6160
Interlocked.Increment(ref orderPlacedErrored);
62-
throw new Exception($"A simulated failure occurred in Shipping Order Placed handling, OrderId: {context.Message.OrderId}, Contents: {string.Join(", ", context.Message.Contents)}");
61+
throw new OrderPlacedException($"A simulated failure occurred in Shipping Order Placed handling, OrderId: {context.Message.OrderId}, Contents: {string.Join(", ", context.Message.Contents)}");
6362
}
6463

6564
Interlocked.Increment(ref orderPlacedProcessed);

0 commit comments

Comments
 (0)