Skip to content
Merged
Changes from 1 commit
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
Next Next commit
Fix MediatR examples exception handlers
  • Loading branch information
alexandruchirita4192 authored May 17, 2022
commit 5a251d070a8b7355bd469769239ae502a0b6a47e
22 changes: 21 additions & 1 deletion samples/MediatR.Examples/ExceptionHandler/ExceptionsHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ protected override async Task Handle(PingResource request,
RequestExceptionHandlerState<Pong> state,
CancellationToken cancellationToken)
{
// Exception type name required because it is checked later in messages
await _writer.WriteLineAsync($"Handling {exception.GetType().FullName}");

// Exception handler type name required because it is checked later in messages
await _writer.WriteLineAsync($"---- Exception Handler: '{typeof(CommonExceptionHandler).FullName}'").ConfigureAwait(false);

state.SetHandled(new Pong());
}
}
Expand All @@ -33,7 +38,12 @@ public async Task Handle(PingResource request,
RequestExceptionHandlerState<Pong> state,
CancellationToken cancellationToken)
{
// Exception type name required because it is checked later in messages
await _writer.WriteLineAsync($"Handling {exception.GetType().FullName}");

// Exception handler type name required because it is checked later in messages
await _writer.WriteLineAsync($"---- Exception Handler: '{typeof(ConnectionExceptionHandler).FullName}'").ConfigureAwait(false);

state.SetHandled(new Pong());
}
}
Expand All @@ -49,7 +59,12 @@ public async Task Handle(PingResource request,
RequestExceptionHandlerState<Pong> state,
CancellationToken cancellationToken)
{
// Exception type name required because it is checked later in messages
await _writer.WriteLineAsync($"Handling {exception.GetType().FullName}");

// Exception handler type name required because it is checked later in messages
await _writer.WriteLineAsync($"---- Exception Handler: '{typeof(AccessDeniedExceptionHandler).FullName}'").ConfigureAwait(false);

state.SetHandled(new Pong());
}
}
Expand All @@ -65,7 +80,12 @@ public virtual async Task Handle(PingNewResource request,
RequestExceptionHandlerState<Pong> state,
CancellationToken cancellationToken)
{
// Exception type name required because it is checked later in messages
await _writer.WriteLineAsync($"Handling {exception.GetType().FullName}");

// Exception handler type name required because it is checked later in messages
await _writer.WriteLineAsync($"---- Exception Handler: '{typeof(ServerExceptionHandler).FullName}'").ConfigureAwait(false);

state.SetHandled(new Pong());
}
}
}