Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/libs/Replicate/Generated/Replicate.Exceptions.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ public partial class ApiException : global::System.Exception
/// </summary>
public global::System.Net.HttpStatusCode StatusCode { get; }
/// <summary>
/// The response body.
/// The response body as a string, or <c>null</c> if the body could not be read.
/// This is always populated for error responses regardless of the <c>ReadResponseAsString</c> setting.
/// For success-path failures (e.g. deserialization errors), the client attempts a best-effort read.
/// </summary>
public string? ResponseBody { get; set; }
/// <summary>
Expand Down
3 changes: 3 additions & 0 deletions src/libs/Replicate/Generated/Replicate.IReplicateClient.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public partial interface IReplicateClient : global::System.IDisposable
/// <summary>
/// Gets or sets a value indicating whether the response content should be read as a string.
/// True by default in debug builds, false otherwise.
/// When false, successful responses are deserialized directly from the response stream for better performance.
/// Error responses are always read as strings regardless of this setting,
/// ensuring <see cref="ApiException.ResponseBody"/> is populated.
/// </summary>
public bool ReadResponseAsString { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,25 @@ partial void ProcessAccountGetResponseContent(
}
catch (global::System.Exception __ex)
{
string? __content = null;
try
{
__content = await __response.Content.ReadAsStringAsync(
#if NET5_0_OR_GREATER
cancellationToken
#endif
).ConfigureAwait(false);
}
catch (global::System.Exception)
{
}

throw new global::Replicate.ApiException(
message: __response.ReasonPhrase ?? string.Empty,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
statusCode: __response.StatusCode)
{
ResponseBody = __content,
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,25 @@ partial void ProcessCollectionsGetResponseContent(
}
catch (global::System.Exception __ex)
{
string? __content = null;
try
{
__content = await __response.Content.ReadAsStringAsync(
#if NET5_0_OR_GREATER
cancellationToken
#endif
).ConfigureAwait(false);
}
catch (global::System.Exception)
{
}

throw new global::Replicate.ApiException(
message: __response.ReasonPhrase ?? string.Empty,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
statusCode: __response.StatusCode)
{
ResponseBody = __content,
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,25 @@ partial void ProcessCollectionsListResponseContent(
}
catch (global::System.Exception __ex)
{
string? __content = null;
try
{
__content = await __response.Content.ReadAsStringAsync(
#if NET5_0_OR_GREATER
cancellationToken
#endif
).ConfigureAwait(false);
}
catch (global::System.Exception)
{
}

throw new global::Replicate.ApiException(
message: __response.ReasonPhrase ?? string.Empty,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
statusCode: __response.StatusCode)
{
ResponseBody = __content,
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,25 @@ partial void ProcessDeploymentsCreateResponseContent(
}
catch (global::System.Exception __ex)
{
string? __content = null;
try
{
__content = await __response.Content.ReadAsStringAsync(
#if NET5_0_OR_GREATER
cancellationToken
#endif
).ConfigureAwait(false);
}
catch (global::System.Exception)
{
}

throw new global::Replicate.ApiException(
message: __response.ReasonPhrase ?? string.Empty,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
statusCode: __response.StatusCode)
{
ResponseBody = __content,
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,25 @@ partial void ProcessDeploymentsDeleteResponse(
}
catch (global::System.Exception __ex)
{
string? __content = null;
try
{
__content = await __response.Content.ReadAsStringAsync(
#if NET5_0_OR_GREATER
cancellationToken
#endif
).ConfigureAwait(false);
}
catch (global::System.Exception)
{
}

throw new global::Replicate.ApiException(
message: __response.ReasonPhrase ?? string.Empty,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
statusCode: __response.StatusCode)
{
ResponseBody = __content,
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,25 @@ partial void ProcessDeploymentsGetResponseContent(
}
catch (global::System.Exception __ex)
{
string? __content = null;
try
{
__content = await __response.Content.ReadAsStringAsync(
#if NET5_0_OR_GREATER
cancellationToken
#endif
).ConfigureAwait(false);
}
catch (global::System.Exception)
{
}

throw new global::Replicate.ApiException(
message: __response.ReasonPhrase ?? string.Empty,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
statusCode: __response.StatusCode)
{
ResponseBody = __content,
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,25 @@ partial void ProcessDeploymentsListResponseContent(
}
catch (global::System.Exception __ex)
{
string? __content = null;
try
{
__content = await __response.Content.ReadAsStringAsync(
#if NET5_0_OR_GREATER
cancellationToken
#endif
).ConfigureAwait(false);
}
catch (global::System.Exception)
{
}

throw new global::Replicate.ApiException(
message: __response.ReasonPhrase ?? string.Empty,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
statusCode: __response.StatusCode)
{
ResponseBody = __content,
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,25 @@ partial void ProcessDeploymentsPredictionsCreateResponseContent(
}
catch (global::System.Exception __ex)
{
string? __content = null;
try
{
__content = await __response.Content.ReadAsStringAsync(
#if NET5_0_OR_GREATER
cancellationToken
#endif
).ConfigureAwait(false);
}
catch (global::System.Exception)
{
}

throw new global::Replicate.ApiException(
message: __response.ReasonPhrase ?? string.Empty,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
statusCode: __response.StatusCode)
{
ResponseBody = __content,
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,25 @@ partial void ProcessDeploymentsUpdateResponseContent(
}
catch (global::System.Exception __ex)
{
string? __content = null;
try
{
__content = await __response.Content.ReadAsStringAsync(
#if NET5_0_OR_GREATER
cancellationToken
#endif
).ConfigureAwait(false);
}
catch (global::System.Exception)
{
}

throw new global::Replicate.ApiException(
message: __response.ReasonPhrase ?? string.Empty,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
statusCode: __response.StatusCode)
{
ResponseBody = __content,
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,9 @@ partial void ProcessFilesCreateResponseContent(
}
else
{
var __contentStream_413 = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
__value_413 = await global::Replicate.FilesCreateResponse.FromJsonStreamAsync(__contentStream_413, JsonSerializerContext).ConfigureAwait(false);
__content_413 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);

__value_413 = global::Replicate.FilesCreateResponse.FromJson(__content_413, JsonSerializerContext);
}
}
catch (global::System.Exception __ex)
Expand Down Expand Up @@ -229,11 +230,25 @@ partial void ProcessFilesCreateResponseContent(
}
catch (global::System.Exception __ex)
{
string? __content = null;
try
{
__content = await __response.Content.ReadAsStringAsync(
#if NET5_0_OR_GREATER
cancellationToken
#endif
).ConfigureAwait(false);
}
catch (global::System.Exception)
{
}

throw new global::Replicate.ApiException(
message: __response.ReasonPhrase ?? string.Empty,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
statusCode: __response.StatusCode)
{
ResponseBody = __content,
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ partial void ProcessFilesDeleteResponse(
}
else
{
var __contentStream_404 = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
__value_404 = await global::Replicate.FilesDeleteResponse.FromJsonStreamAsync(__contentStream_404, JsonSerializerContext).ConfigureAwait(false);
__content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);

__value_404 = global::Replicate.FilesDeleteResponse.FromJson(__content_404, JsonSerializerContext);
}
}
catch (global::System.Exception __ex)
Expand Down Expand Up @@ -172,11 +173,25 @@ partial void ProcessFilesDeleteResponse(
}
catch (global::System.Exception __ex)
{
string? __content = null;
try
{
__content = await __response.Content.ReadAsStringAsync(
#if NET5_0_OR_GREATER
cancellationToken
#endif
).ConfigureAwait(false);
}
catch (global::System.Exception)
{
}

throw new global::Replicate.ApiException(
message: __response.ReasonPhrase ?? string.Empty,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
statusCode: __response.StatusCode)
{
ResponseBody = __content,
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ partial void ProcessFilesDownloadResponseContent(
}
else
{
var __contentStream_404 = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
__value_404 = await global::Replicate.FilesDownloadResponse.FromJsonStreamAsync(__contentStream_404, JsonSerializerContext).ConfigureAwait(false);
__content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);

__value_404 = global::Replicate.FilesDownloadResponse.FromJson(__content_404, JsonSerializerContext);
}
}
catch (global::System.Exception __ex)
Expand Down Expand Up @@ -199,11 +200,25 @@ partial void ProcessFilesDownloadResponseContent(
}
catch (global::System.Exception __ex)
{
string? __content = null;
try
{
__content = await __response.Content.ReadAsStringAsync(
#if NET5_0_OR_GREATER
cancellationToken
#endif
).ConfigureAwait(false);
}
catch (global::System.Exception)
{
}

throw new global::Replicate.ApiException(
message: __response.ReasonPhrase ?? string.Empty,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
statusCode: __response.StatusCode)
{
ResponseBody = __content,
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
Expand Down
Loading