// Copyright Epic Games, Inc. All Rights Reserved.
using Grpc.Core;
namespace HordeAgent.Utility
{
///
/// Utility methods for exceptions
///
static class ExceptionUtils
{
///
/// Determine if the given exception was triggered due to a cancellation event
///
/// The exception to check
/// True if the exception is a cancellation exception
public static bool IsCancellationException(this Exception ex)
{
if (ex is OperationCanceledException)
{
return true;
}
RpcException? rpcException = ex as RpcException;
if (rpcException != null && rpcException.StatusCode == StatusCode.Cancelled)
{
return true;
}
return false;
}
}
}