Skip to content

Commit 699150a

Browse files
Improved error message in OutboxMessageProcessor<>
1 parent b3b8317 commit 699150a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/DotNetElements.AppFramework/Outbox/OutboxMessageProcessor.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
public interface IOutboxMessageProcessor
44
{
5-
Task<ResultWithError> ProcessAsync(object message, CancellationToken cancellation);
5+
Task<ResultWithError> ProcessAsync(object message, CancellationToken cancellation);
66
}
77

88
public abstract class OutboxMessageProcessor<T> : IOutboxMessageProcessor
99
{
10-
public Task<ResultWithError> ProcessAsync(object message, CancellationToken cancellation)
11-
{
12-
if (message is not T tMessage)
13-
throw new ArgumentException("Invalid message type");
10+
public Task<ResultWithError> ProcessAsync(object message, CancellationToken cancellation)
11+
{
12+
if (message is not T typedMessage)
13+
throw new ArgumentException($"Invalid message type: {message.GetType().Name}. Expected: {typeof(T).Name}.");
1414

15-
return ProcessAsync(tMessage, cancellation);
16-
}
15+
return ProcessAsync(typedMessage, cancellation);
16+
}
1717

18-
protected abstract Task<ResultWithError> ProcessAsync(T message, CancellationToken cancellation);
18+
protected abstract Task<ResultWithError> ProcessAsync(T message, CancellationToken cancellation);
1919
}

0 commit comments

Comments
 (0)