mirror of
https://github.com/jlengrand/openapi-generator.git
synced 2026-03-10 08:31:23 +00:00
[csharp-netcore] HttpClient/Set TimeoutException to inner exception in case of timeout (#13862)
* Changed to TimeoutException * Handle timeout exceptions as inner exceptions. * Corrected arguments for compatibility
This commit is contained in:
@@ -531,6 +531,15 @@ namespace {{packageName}}.Client
|
||||
|
||||
return await ToApiResponse<T>(response, responseData, req.RequestUri);
|
||||
}
|
||||
catch (OperationCanceledException original)
|
||||
{
|
||||
if (timeoutTokenSource != null && timeoutTokenSource.IsCancellationRequested)
|
||||
{
|
||||
throw new TaskCanceledException($"[{req.Method}] {req.RequestUri} was timeout.",
|
||||
new TimeoutException(original.Message, original));
|
||||
}
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (timeoutTokenSource != null)
|
||||
|
||||
@@ -533,6 +533,15 @@ namespace {{packageName}}.Client
|
||||
|
||||
return await ToApiResponse<T>(response, responseData, req.RequestUri);
|
||||
}
|
||||
catch (OperationCanceledException original)
|
||||
{
|
||||
if (timeoutTokenSource != null && timeoutTokenSource.IsCancellationRequested)
|
||||
{
|
||||
throw new TaskCanceledException($"[{req.Method}] {req.RequestUri} was timeout.",
|
||||
new TimeoutException(original.Message, original));
|
||||
}
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (timeoutTokenSource != null)
|
||||
|
||||
@@ -530,6 +530,15 @@ namespace Org.OpenAPITools.Client
|
||||
|
||||
return await ToApiResponse<T>(response, responseData, req.RequestUri);
|
||||
}
|
||||
catch (OperationCanceledException original)
|
||||
{
|
||||
if (timeoutTokenSource != null && timeoutTokenSource.IsCancellationRequested)
|
||||
{
|
||||
throw new TaskCanceledException($"[{req.Method}] {req.RequestUri} was timeout.",
|
||||
new TimeoutException(original.Message, original));
|
||||
}
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (timeoutTokenSource != null)
|
||||
|
||||
Reference in New Issue
Block a user