Files
Wireless_Eink_HomeScreen/HomeApi/Extensions/MediatorExtensions.cs
Myx f0344bd3ba fix: crash on unavailable source api
the screen not updating because of errors
2025-08-14 17:02:48 +02:00

22 lines
487 B
C#

using MediatR;
namespace HomeApi.Extensions;
public static class MediatorExtensions
{
public static async Task<T?> TrySendAsync<T>(
this IMediator mediator,
IRequest<T> request,
CancellationToken cancellationToken) where T : class
{
try
{
return await mediator.Send(request, cancellationToken);
}
catch (OperationCanceledException) { throw; }
catch
{
return null;
}
}
}