diff --git a/src/libs/Descript/Generated/Descript.ApiEndpointsClient.AgentEditJob.g.cs b/src/libs/Descript/Generated/Descript.ApiEndpointsClient.AgentEditJob.g.cs index 2e43e46..ea084d1 100644 --- a/src/libs/Descript/Generated/Descript.ApiEndpointsClient.AgentEditJob.g.cs +++ b/src/libs/Descript/Generated/Descript.ApiEndpointsClient.AgentEditJob.g.cs @@ -390,18 +390,17 @@ partial void ProcessAgentEditJobResponseContent( __exception_400 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_400, + responseObject: __value_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Unauthorized - missing or invalid authentication token if ((int)__response.StatusCode == 401) @@ -428,18 +427,17 @@ partial void ProcessAgentEditJobResponseContent( __exception_401 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_401, - statusCode: __response.StatusCode) - { - ResponseBody = __content_401, - ResponseObject = __value_401, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Payment Required - insufficient AI credits to start the job if ((int)__response.StatusCode == 402) @@ -466,18 +464,17 @@ partial void ProcessAgentEditJobResponseContent( __exception_402 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_402 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_402, - statusCode: __response.StatusCode) - { - ResponseBody = __content_402, - ResponseObject = __value_402, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_402, + responseObject: __value_402, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Not found: - Project doesn't exist - Composition doesn't exist in the specified project (when composition_id is provided) if ((int)__response.StatusCode == 404) @@ -504,18 +501,17 @@ partial void ProcessAgentEditJobResponseContent( __exception_404 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_404, + responseObject: __value_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Too many requests - rate limit exceeded. Use the `Retry-After` header to determine when to retry. if ((int)__response.StatusCode == 429) @@ -542,18 +538,17 @@ partial void ProcessAgentEditJobResponseContent( __exception_429 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_429, - statusCode: __response.StatusCode) - { - ResponseBody = __content_429, - ResponseObject = __value_429, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_429, + responseObject: __value_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } if (__effectiveReadResponseAsString) @@ -587,17 +582,15 @@ partial void ProcessAgentEditJobResponseContent( } catch (global::System.Exception __ex) { - throw new global::Descript.ApiException( + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content ?? __response.ReasonPhrase ?? string.Empty, innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } } else @@ -634,17 +627,15 @@ partial void ProcessAgentEditJobResponseContent( { } - throw new global::Descript.ApiException( + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content ?? __response.ReasonPhrase ?? string.Empty, innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } } diff --git a/src/libs/Descript/Generated/Descript.ApiEndpointsClient.CancelJob.g.cs b/src/libs/Descript/Generated/Descript.ApiEndpointsClient.CancelJob.g.cs index f657708..9115d91 100644 --- a/src/libs/Descript/Generated/Descript.ApiEndpointsClient.CancelJob.g.cs +++ b/src/libs/Descript/Generated/Descript.ApiEndpointsClient.CancelJob.g.cs @@ -344,18 +344,17 @@ await CancelJobAsResponseAsync( __exception_401 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_401, - statusCode: __response.StatusCode) - { - ResponseBody = __content_401, - ResponseObject = __value_401, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Forbidden - user does not have access to this job if ((int)__response.StatusCode == 403) @@ -382,18 +381,17 @@ await CancelJobAsResponseAsync( __exception_403 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_403, - statusCode: __response.StatusCode) - { - ResponseBody = __content_403, - ResponseObject = __value_403, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_403, + responseObject: __value_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Job not found if ((int)__response.StatusCode == 404) @@ -420,18 +418,17 @@ await CancelJobAsResponseAsync( __exception_404 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_404, + responseObject: __value_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Too many requests - rate limit exceeded. Use the `Retry-After` header to determine when to retry. if ((int)__response.StatusCode == 429) @@ -458,18 +455,17 @@ await CancelJobAsResponseAsync( __exception_429 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_429, - statusCode: __response.StatusCode) - { - ResponseBody = __content_429, - ResponseObject = __value_429, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_429, + responseObject: __value_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } if (__effectiveReadResponseAsString) @@ -496,17 +492,15 @@ await CancelJobAsResponseAsync( } catch (global::System.Exception __ex) { - throw new global::Descript.ApiException( + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content ?? __response.ReasonPhrase ?? string.Empty, innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } } else @@ -534,17 +528,15 @@ await CancelJobAsResponseAsync( { } - throw new global::Descript.ApiException( + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content ?? __response.ReasonPhrase ?? string.Empty, innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } } diff --git a/src/libs/Descript/Generated/Descript.ApiEndpointsClient.GetJob.g.cs b/src/libs/Descript/Generated/Descript.ApiEndpointsClient.GetJob.g.cs index a944569..b88904e 100644 --- a/src/libs/Descript/Generated/Descript.ApiEndpointsClient.GetJob.g.cs +++ b/src/libs/Descript/Generated/Descript.ApiEndpointsClient.GetJob.g.cs @@ -353,18 +353,17 @@ partial void ProcessGetJobResponseContent( __exception_401 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_401, - statusCode: __response.StatusCode) - { - ResponseBody = __content_401, - ResponseObject = __value_401, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Forbidden - user does not have access to this job if ((int)__response.StatusCode == 403) @@ -391,18 +390,17 @@ partial void ProcessGetJobResponseContent( __exception_403 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_403, - statusCode: __response.StatusCode) - { - ResponseBody = __content_403, - ResponseObject = __value_403, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_403, + responseObject: __value_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Job not found if ((int)__response.StatusCode == 404) @@ -429,18 +427,17 @@ partial void ProcessGetJobResponseContent( __exception_404 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_404, + responseObject: __value_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Too many requests - rate limit exceeded. Use the `Retry-After` header to determine when to retry. if ((int)__response.StatusCode == 429) @@ -467,18 +464,17 @@ partial void ProcessGetJobResponseContent( __exception_429 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_429, - statusCode: __response.StatusCode) - { - ResponseBody = __content_429, - ResponseObject = __value_429, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_429, + responseObject: __value_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } if (__effectiveReadResponseAsString) @@ -512,17 +508,15 @@ partial void ProcessGetJobResponseContent( } catch (global::System.Exception __ex) { - throw new global::Descript.ApiException( + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content ?? __response.ReasonPhrase ?? string.Empty, innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } } else @@ -559,17 +553,15 @@ partial void ProcessGetJobResponseContent( { } - throw new global::Descript.ApiException( + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content ?? __response.ReasonPhrase ?? string.Empty, innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } } diff --git a/src/libs/Descript/Generated/Descript.ApiEndpointsClient.GetProject.g.cs b/src/libs/Descript/Generated/Descript.ApiEndpointsClient.GetProject.g.cs index 1e1435f..195130e 100644 --- a/src/libs/Descript/Generated/Descript.ApiEndpointsClient.GetProject.g.cs +++ b/src/libs/Descript/Generated/Descript.ApiEndpointsClient.GetProject.g.cs @@ -359,18 +359,17 @@ partial void ProcessGetProjectResponseContent( __exception_400 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_400, + responseObject: __value_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Unauthorized - invalid or missing authentication token if ((int)__response.StatusCode == 401) @@ -397,18 +396,17 @@ partial void ProcessGetProjectResponseContent( __exception_401 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_401, - statusCode: __response.StatusCode) - { - ResponseBody = __content_401, - ResponseObject = __value_401, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Forbidden - user does not have access to this project if ((int)__response.StatusCode == 403) @@ -435,18 +433,17 @@ partial void ProcessGetProjectResponseContent( __exception_403 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_403, - statusCode: __response.StatusCode) - { - ResponseBody = __content_403, - ResponseObject = __value_403, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_403, + responseObject: __value_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Project not found if ((int)__response.StatusCode == 404) @@ -473,18 +470,17 @@ partial void ProcessGetProjectResponseContent( __exception_404 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_404, + responseObject: __value_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Too many requests - rate limit exceeded. Use the `Retry-After` header to determine when to retry. if ((int)__response.StatusCode == 429) @@ -511,18 +507,17 @@ partial void ProcessGetProjectResponseContent( __exception_429 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_429, - statusCode: __response.StatusCode) - { - ResponseBody = __content_429, - ResponseObject = __value_429, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_429, + responseObject: __value_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } if (__effectiveReadResponseAsString) @@ -556,17 +551,15 @@ partial void ProcessGetProjectResponseContent( } catch (global::System.Exception __ex) { - throw new global::Descript.ApiException( + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content ?? __response.ReasonPhrase ?? string.Empty, innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } } else @@ -603,17 +596,15 @@ partial void ProcessGetProjectResponseContent( { } - throw new global::Descript.ApiException( + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content ?? __response.ReasonPhrase ?? string.Empty, innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } } diff --git a/src/libs/Descript/Generated/Descript.ApiEndpointsClient.GetStatus.g.cs b/src/libs/Descript/Generated/Descript.ApiEndpointsClient.GetStatus.g.cs index 7b49b6a..5ecde6a 100644 --- a/src/libs/Descript/Generated/Descript.ApiEndpointsClient.GetStatus.g.cs +++ b/src/libs/Descript/Generated/Descript.ApiEndpointsClient.GetStatus.g.cs @@ -352,18 +352,17 @@ partial void ProcessGetStatusResponseContent( __exception_401 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_401, - statusCode: __response.StatusCode) - { - ResponseBody = __content_401, - ResponseObject = __value_401, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } if (__effectiveReadResponseAsString) @@ -397,17 +396,15 @@ partial void ProcessGetStatusResponseContent( } catch (global::System.Exception __ex) { - throw new global::Descript.ApiException( + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content ?? __response.ReasonPhrase ?? string.Empty, innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } } else @@ -444,17 +441,15 @@ partial void ProcessGetStatusResponseContent( { } - throw new global::Descript.ApiException( + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content ?? __response.ReasonPhrase ?? string.Empty, innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } } diff --git a/src/libs/Descript/Generated/Descript.ApiEndpointsClient.ImportProjectMedia.g.cs b/src/libs/Descript/Generated/Descript.ApiEndpointsClient.ImportProjectMedia.g.cs index 89a7f16..b730e64 100644 --- a/src/libs/Descript/Generated/Descript.ApiEndpointsClient.ImportProjectMedia.g.cs +++ b/src/libs/Descript/Generated/Descript.ApiEndpointsClient.ImportProjectMedia.g.cs @@ -398,18 +398,17 @@ partial void ProcessImportProjectMediaResponseContent( __exception_400 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_400, + responseObject: __value_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Unauthorized - missing or invalid authentication token if ((int)__response.StatusCode == 401) @@ -436,18 +435,17 @@ partial void ProcessImportProjectMediaResponseContent( __exception_401 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_401, - statusCode: __response.StatusCode) - { - ResponseBody = __content_401, - ResponseObject = __value_401, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Payment Required - insufficient media minutes to start the job if ((int)__response.StatusCode == 402) @@ -474,18 +472,17 @@ partial void ProcessImportProjectMediaResponseContent( __exception_402 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_402 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_402, - statusCode: __response.StatusCode) - { - ResponseBody = __content_402, - ResponseObject = __value_402, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_402, + responseObject: __value_402, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Forbidden - user does not have access to this resource if ((int)__response.StatusCode == 403) @@ -512,18 +509,17 @@ partial void ProcessImportProjectMediaResponseContent( __exception_403 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_403, - statusCode: __response.StatusCode) - { - ResponseBody = __content_403, - ResponseObject = __value_403, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_403, + responseObject: __value_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Not found: - Drive doesn't exist - Project doesn't exist (when project_id is provided) if ((int)__response.StatusCode == 404) @@ -550,18 +546,17 @@ partial void ProcessImportProjectMediaResponseContent( __exception_404 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_404, + responseObject: __value_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Too many requests - rate limit exceeded. Use the `Retry-After` header to determine when to retry. if ((int)__response.StatusCode == 429) @@ -588,18 +583,17 @@ partial void ProcessImportProjectMediaResponseContent( __exception_429 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_429, - statusCode: __response.StatusCode) - { - ResponseBody = __content_429, - ResponseObject = __value_429, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_429, + responseObject: __value_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } if (__effectiveReadResponseAsString) @@ -633,17 +627,15 @@ partial void ProcessImportProjectMediaResponseContent( } catch (global::System.Exception __ex) { - throw new global::Descript.ApiException( + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content ?? __response.ReasonPhrase ?? string.Empty, innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } } else @@ -680,17 +672,15 @@ partial void ProcessImportProjectMediaResponseContent( { } - throw new global::Descript.ApiException( + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content ?? __response.ReasonPhrase ?? string.Empty, innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } } diff --git a/src/libs/Descript/Generated/Descript.ApiEndpointsClient.ListJobs.g.cs b/src/libs/Descript/Generated/Descript.ApiEndpointsClient.ListJobs.g.cs index eee189d..7296e70 100644 --- a/src/libs/Descript/Generated/Descript.ApiEndpointsClient.ListJobs.g.cs +++ b/src/libs/Descript/Generated/Descript.ApiEndpointsClient.ListJobs.g.cs @@ -422,18 +422,17 @@ partial void ProcessListJobsResponseContent( __exception_400 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_400, + responseObject: __value_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Unauthorized - invalid or missing authentication token if ((int)__response.StatusCode == 401) @@ -460,18 +459,17 @@ partial void ProcessListJobsResponseContent( __exception_401 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_401, - statusCode: __response.StatusCode) - { - ResponseBody = __content_401, - ResponseObject = __value_401, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Too many requests - rate limit exceeded. Use the `Retry-After` header to determine when to retry. if ((int)__response.StatusCode == 429) @@ -498,18 +496,17 @@ partial void ProcessListJobsResponseContent( __exception_429 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_429, - statusCode: __response.StatusCode) - { - ResponseBody = __content_429, - ResponseObject = __value_429, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_429, + responseObject: __value_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } if (__effectiveReadResponseAsString) @@ -543,17 +540,15 @@ partial void ProcessListJobsResponseContent( } catch (global::System.Exception __ex) { - throw new global::Descript.ApiException( + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content ?? __response.ReasonPhrase ?? string.Empty, innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } } else @@ -590,17 +585,15 @@ partial void ProcessListJobsResponseContent( { } - throw new global::Descript.ApiException( + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content ?? __response.ReasonPhrase ?? string.Empty, innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } } diff --git a/src/libs/Descript/Generated/Descript.ApiEndpointsClient.ListProjects.g.cs b/src/libs/Descript/Generated/Descript.ApiEndpointsClient.ListProjects.g.cs index 932c368..989f5bb 100644 --- a/src/libs/Descript/Generated/Descript.ApiEndpointsClient.ListProjects.g.cs +++ b/src/libs/Descript/Generated/Descript.ApiEndpointsClient.ListProjects.g.cs @@ -472,18 +472,17 @@ partial void ProcessListProjectsResponseContent( __exception_401 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_401, - statusCode: __response.StatusCode) - { - ResponseBody = __content_401, - ResponseObject = __value_401, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Too many requests - rate limit exceeded. Use the `Retry-After` header to determine when to retry. if ((int)__response.StatusCode == 429) @@ -510,18 +509,17 @@ partial void ProcessListProjectsResponseContent( __exception_429 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_429, - statusCode: __response.StatusCode) - { - ResponseBody = __content_429, - ResponseObject = __value_429, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_429, + responseObject: __value_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } if (__effectiveReadResponseAsString) @@ -555,17 +553,15 @@ partial void ProcessListProjectsResponseContent( } catch (global::System.Exception __ex) { - throw new global::Descript.ApiException( + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content ?? __response.ReasonPhrase ?? string.Empty, innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } } else @@ -602,17 +598,15 @@ partial void ProcessListProjectsResponseContent( { } - throw new global::Descript.ApiException( + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content ?? __response.ReasonPhrase ?? string.Empty, innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } } diff --git a/src/libs/Descript/Generated/Descript.ApiEndpointsClient.PublishJob.g.cs b/src/libs/Descript/Generated/Descript.ApiEndpointsClient.PublishJob.g.cs index 8b392bd..66ae8af 100644 --- a/src/libs/Descript/Generated/Descript.ApiEndpointsClient.PublishJob.g.cs +++ b/src/libs/Descript/Generated/Descript.ApiEndpointsClient.PublishJob.g.cs @@ -394,18 +394,17 @@ partial void ProcessPublishJobResponseContent( __exception_400 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_400, + responseObject: __value_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Unauthorized - missing or invalid authentication token if ((int)__response.StatusCode == 401) @@ -432,18 +431,17 @@ partial void ProcessPublishJobResponseContent( __exception_401 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_401, - statusCode: __response.StatusCode) - { - ResponseBody = __content_401, - ResponseObject = __value_401, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Forbidden: - User doesn't have write access to the project - Project doesn't belong to the token's drive - Requested `access_level` is not permitted by the drive's publish settings if ((int)__response.StatusCode == 403) @@ -470,18 +468,17 @@ partial void ProcessPublishJobResponseContent( __exception_403 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_403, - statusCode: __response.StatusCode) - { - ResponseBody = __content_403, - ResponseObject = __value_403, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_403, + responseObject: __value_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // if ((int)__response.StatusCode == 422) @@ -504,17 +501,16 @@ partial void ProcessPublishJobResponseContent( __exception_422 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_422, - statusCode: __response.StatusCode) - { - ResponseBody = __content_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_422, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Too many requests - rate limit exceeded. Use the `Retry-After` header to determine when to retry. if ((int)__response.StatusCode == 429) @@ -541,18 +537,17 @@ partial void ProcessPublishJobResponseContent( __exception_429 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_429, - statusCode: __response.StatusCode) - { - ResponseBody = __content_429, - ResponseObject = __value_429, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_429, + responseObject: __value_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } if (__effectiveReadResponseAsString) @@ -586,17 +581,15 @@ partial void ProcessPublishJobResponseContent( } catch (global::System.Exception __ex) { - throw new global::Descript.ApiException( + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content ?? __response.ReasonPhrase ?? string.Empty, innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } } else @@ -633,17 +626,15 @@ partial void ProcessPublishJobResponseContent( { } - throw new global::Descript.ApiException( + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content ?? __response.ReasonPhrase ?? string.Empty, innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } } diff --git a/src/libs/Descript/Generated/Descript.EditInDescriptClient.PostEditInDescriptSchema.g.cs b/src/libs/Descript/Generated/Descript.EditInDescriptClient.PostEditInDescriptSchema.g.cs index 25719ed..ec01002 100644 --- a/src/libs/Descript/Generated/Descript.EditInDescriptClient.PostEditInDescriptSchema.g.cs +++ b/src/libs/Descript/Generated/Descript.EditInDescriptClient.PostEditInDescriptSchema.g.cs @@ -426,17 +426,16 @@ partial void ProcessPostEditInDescriptSchemaResponseContent( __exception_400 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // if ((int)__response.StatusCode == 403) @@ -459,17 +458,16 @@ partial void ProcessPostEditInDescriptSchemaResponseContent( __exception_403 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_403, - statusCode: __response.StatusCode) - { - ResponseBody = __content_403, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Too many requests - rate limit exceeded. Use the `Retry-After` header to determine when to retry. if ((int)__response.StatusCode == 429) @@ -496,18 +494,17 @@ partial void ProcessPostEditInDescriptSchemaResponseContent( __exception_429 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_429, - statusCode: __response.StatusCode) - { - ResponseBody = __content_429, - ResponseObject = __value_429, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_429, + responseObject: __value_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } if (__effectiveReadResponseAsString) @@ -541,17 +538,15 @@ partial void ProcessPostEditInDescriptSchemaResponseContent( } catch (global::System.Exception __ex) { - throw new global::Descript.ApiException( + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content ?? __response.ReasonPhrase ?? string.Empty, innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } } else @@ -588,17 +583,15 @@ partial void ProcessPostEditInDescriptSchemaResponseContent( { } - throw new global::Descript.ApiException( + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content ?? __response.ReasonPhrase ?? string.Empty, innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } } diff --git a/src/libs/Descript/Generated/Descript.Exceptions.g.cs b/src/libs/Descript/Generated/Descript.Exceptions.g.cs index 7f3f806..49fdde6 100644 --- a/src/libs/Descript/Generated/Descript.Exceptions.g.cs +++ b/src/libs/Descript/Generated/Descript.Exceptions.g.cs @@ -12,16 +12,19 @@ public partial class ApiException : global::System.Exception /// The HTTP status code of the response. /// public global::System.Net.HttpStatusCode StatusCode { get; } + /// /// The response body as a string, or null if the body could not be read. /// This is always populated for error responses regardless of the ReadResponseAsString setting. /// For success-path failures (e.g. deserialization errors), the client attempts a best-effort read. /// public string? ResponseBody { get; set; } + /// /// The response headers. /// public global::System.Collections.Generic.Dictionary>? ResponseHeaders { get; set; } + /// /// Initializes a new instance of the class. /// @@ -49,6 +52,103 @@ public ApiException(string message, global::System.Exception? innerException, gl { StatusCode = statusCode; } + + /// + /// Constructs an instance whose runtime type matches the response status code when the typed exception hierarchy is enabled. Always returns a plain when the hierarchy is disabled. + /// + /// The HTTP status code of the response. + /// The error message. + /// An inner exception, when one is available. + /// The response headers; consulted for 429 Retry-After parsing when present. + public static global::Descript.ApiException Create( + global::System.Net.HttpStatusCode statusCode, + string message, + global::System.Exception? innerException = null, + global::System.Collections.Generic.IDictionary>? responseHeaders = null) + { + return new global::Descript.ApiException(message, innerException, statusCode); + } + + /// + /// Convenience overload that constructs an with response body and headers populated. + /// + public static global::Descript.ApiException Create( + global::System.Net.HttpStatusCode statusCode, + string message, + global::System.Exception? innerException, + string? responseBody, + global::System.Collections.Generic.Dictionary>? responseHeaders) + { + var exception = global::Descript.ApiException.Create(statusCode, message, innerException, responseHeaders); + exception.ResponseBody = responseBody; + exception.ResponseHeaders = responseHeaders; + return exception; + } + + /// + /// Parses a Retry-After response header (delta-seconds or HTTP-date) into a . + /// Returns null when the header is missing or unparseable. Public so consumer code that observes + /// directly can recover the value without re-implementing the parser. + /// + public static global::System.TimeSpan? TryParseRetryAfter( + global::System.Collections.Generic.IDictionary>? headers) + { + if (headers == null) + { + return null; + } + + global::System.Collections.Generic.IEnumerable? values = null; + foreach (var entry in headers) + { + if (string.Equals(entry.Key, "Retry-After", global::System.StringComparison.OrdinalIgnoreCase)) + { + values = entry.Value; + break; + } + } + + if (values == null) + { + return null; + } + + string? raw = null; + foreach (var value in values) + { + if (!string.IsNullOrWhiteSpace(value)) + { + raw = value.Trim(); + break; + } + } + + if (string.IsNullOrEmpty(raw)) + { + return null; + } + + if (int.TryParse( + raw, + global::System.Globalization.NumberStyles.Integer, + global::System.Globalization.CultureInfo.InvariantCulture, + out var seconds) && seconds >= 0) + { + return global::System.TimeSpan.FromSeconds(seconds); + } + + if (global::System.DateTimeOffset.TryParse( + raw, + global::System.Globalization.CultureInfo.InvariantCulture, + global::System.Globalization.DateTimeStyles.AssumeUniversal | global::System.Globalization.DateTimeStyles.AdjustToUniversal, + out var when)) + { + var delta = when - global::System.DateTimeOffset.UtcNow; + return delta > global::System.TimeSpan.Zero ? delta : global::System.TimeSpan.Zero; + } + + return null; + } } /// @@ -88,5 +188,39 @@ public ApiException(string message, global::System.Net.HttpStatusCode statusCode public ApiException(string message, global::System.Exception? innerException, global::System.Net.HttpStatusCode statusCode) : base(message, innerException, statusCode) { } + + /// + /// Constructs an whose runtime type matches the response status code when the typed exception hierarchy is enabled. + /// + /// The HTTP status code of the response. + /// The error message. + /// An inner exception, when one is available. + /// The response headers; consulted for 429 Retry-After parsing when present. + public static new global::Descript.ApiException Create( + global::System.Net.HttpStatusCode statusCode, + string message, + global::System.Exception? innerException = null, + global::System.Collections.Generic.IDictionary>? responseHeaders = null) + { + return new global::Descript.ApiException(message, innerException, statusCode); + } + + /// + /// Convenience overload that constructs an with response body, object, and headers populated. + /// + public static global::Descript.ApiException Create( + global::System.Net.HttpStatusCode statusCode, + string message, + global::System.Exception? innerException, + string? responseBody, + T? responseObject, + global::System.Collections.Generic.Dictionary>? responseHeaders) + { + var exception = global::Descript.ApiException.Create(statusCode, message, innerException, responseHeaders); + exception.ResponseBody = responseBody; + exception.ResponseObject = responseObject; + exception.ResponseHeaders = responseHeaders; + return exception; + } } } \ No newline at end of file diff --git a/src/libs/Descript/Generated/Descript.ExportFromDescriptClient.GetPublishedProjectMetadata.g.cs b/src/libs/Descript/Generated/Descript.ExportFromDescriptClient.GetPublishedProjectMetadata.g.cs index 6bf9e28..ae3be45 100644 --- a/src/libs/Descript/Generated/Descript.ExportFromDescriptClient.GetPublishedProjectMetadata.g.cs +++ b/src/libs/Descript/Generated/Descript.ExportFromDescriptClient.GetPublishedProjectMetadata.g.cs @@ -357,18 +357,17 @@ partial void ProcessGetPublishedProjectMetadataResponseContent( __exception_401 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_401, - statusCode: __response.StatusCode) - { - ResponseBody = __content_401, - ResponseObject = __value_401, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Forbidden - user does not have access to this published project. if ((int)__response.StatusCode == 403) @@ -395,18 +394,17 @@ partial void ProcessGetPublishedProjectMetadataResponseContent( __exception_403 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_403, - statusCode: __response.StatusCode) - { - ResponseBody = __content_403, - ResponseObject = __value_403, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_403, + responseObject: __value_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Not found - published project does not exist. if ((int)__response.StatusCode == 404) @@ -433,18 +431,17 @@ partial void ProcessGetPublishedProjectMetadataResponseContent( __exception_404 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_404, + responseObject: __value_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Conflict - published project is in an invalid state (processing or failed). if ((int)__response.StatusCode == 409) @@ -471,18 +468,17 @@ partial void ProcessGetPublishedProjectMetadataResponseContent( __exception_409 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_409 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_409, - statusCode: __response.StatusCode) - { - ResponseBody = __content_409, - ResponseObject = __value_409, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_409, + responseObject: __value_409, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } // Too many requests - rate limit exceeded. Use the `Retry-After` header to determine when to retry. if ((int)__response.StatusCode == 429) @@ -509,18 +505,17 @@ partial void ProcessGetPublishedProjectMetadataResponseContent( __exception_429 = __ex; } - throw new global::Descript.ApiException( + + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, innerException: __exception_429, - statusCode: __response.StatusCode) - { - ResponseBody = __content_429, - ResponseObject = __value_429, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content_429, + responseObject: __value_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } if (__effectiveReadResponseAsString) @@ -554,17 +549,15 @@ partial void ProcessGetPublishedProjectMetadataResponseContent( } catch (global::System.Exception __ex) { - throw new global::Descript.ApiException( + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content ?? __response.ReasonPhrase ?? string.Empty, innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } } else @@ -601,17 +594,15 @@ partial void ProcessGetPublishedProjectMetadataResponseContent( { } - throw new global::Descript.ApiException( + throw global::Descript.ApiException.Create( + statusCode: __response.StatusCode, message: __content ?? __response.ReasonPhrase ?? string.Empty, innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, - h => h.Value), - }; + h => h.Value)); } }