TimeoutRejectedException
Exception thrown when a delegate executed through a timeout resilience strategy does not complete, before the configured timeout.
using Polly.Utils;
using System;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Threading;
namespace Polly.Timeout
{
[Serializable]
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
public class TimeoutRejectedException : ExecutionRejectedException
{
public TimeSpan Timeout { get; set; } = System.Threading.Timeout.InfiniteTimeSpan;
public TimeoutRejectedException()
: base("The operation didn't complete within the allowed timeout.")
{
}
public TimeoutRejectedException(string message)
: base(message)
{
}
public TimeoutRejectedException(string message, Exception innerException)
: base(message, innerException)
{
}
public TimeoutRejectedException(TimeSpan timeout)
: base("The operation didn't complete within the allowed timeout.")
{
Timeout = timeout;
}
public TimeoutRejectedException(string message, TimeSpan timeout)
: base(message)
{
Timeout = timeout;
}
public TimeoutRejectedException(string message, TimeSpan timeout, Exception innerException)
: base(message, innerException)
{
Timeout = timeout;
}
private TimeoutRejectedException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
Timeout = TimeSpan.FromSeconds(info.GetDouble("Timeout"));
}
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
Guard.NotNull(info, "info");
info.AddValue("Timeout", Timeout.TotalSeconds);
base.GetObjectData(info, context);
}
}
}