Class CurlTimeoutException
- Namespace
- CurlDotNet.Exceptions
- Assembly
- CurlDotNet.dll
Thrown when an operation exceeds the configured timeout period.
[Serializable]
public class CurlTimeoutException : CurlException, ISerializable
- Inheritance
-
CurlTimeoutException
- Implements
- Derived
- Inherited Members
Examples
try
{
// Set a 5 second timeout
var result = await curl.ExecuteAsync("curl --max-time 5 https://slow-server.com/large-file");
}
catch (CurlTimeoutException ex)
{
Console.WriteLine($"Operation timed out after {ex.Timeout?.TotalSeconds ?? 0} seconds");
// Retry with longer timeout
Console.WriteLine("Retrying with 30 second timeout...");
result = await curl.ExecuteAsync("curl --max-time 30 https://slow-server.com/large-file");
}
Remarks
This can occur for connection timeout or total operation timeout.
Curl error code: CURLE_OPERATION_TIMEDOUT (28)
AI-Usage: Catch this to implement retry with longer timeout or fail fast.
AI-Pattern: Log timeout value to help diagnose if timeout is too short.
Constructors
CurlTimeoutException(SerializationInfo, StreamingContext)
Initializes a new instance with serialized data.
protected CurlTimeoutException(SerializationInfo info, StreamingContext context)
Parameters
infoSerializationInfocontextStreamingContext
CurlTimeoutException(string, string, TimeSpan?)
Initializes a new instance of the CurlTimeoutException class.
public CurlTimeoutException(string message, string command = null, TimeSpan? timeout = null)
Parameters
messagestringThe error message describing the timeout.
commandstringThe curl command that was executing.
timeoutTimeSpan?The timeout duration that was exceeded.
Properties
Timeout
Gets the timeout duration that was exceeded.
public TimeSpan? Timeout { get; }
Property Value
- TimeSpan?
The timeout duration, or null if not specified.
Remarks
This represents the --max-time or --connect-timeout value that was exceeded.
AI-Usage: Use this to determine if timeout should be increased.
Methods
GetObjectData(SerializationInfo, StreamingContext)
Sets the SerializationInfo with information about the exception.
public override void GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
infoSerializationInfoThe serialization information.
contextStreamingContextThe streaming context.