protected override void ExtractFailureContent( string?content, ResponseHeaders responseHeaders, ref string?message, ref string?errorCode, ref IDictionary <string, string>?additionalInfo) { if (!string.IsNullOrEmpty(content)) { try { // Try to parse the failure content and use that as the // default value for the message, error code, etc. using JsonDocument doc = JsonDocument.Parse(content); if (doc.RootElement.TryGetProperty("error", out JsonElement errorElement)) { TextAnalyticsError error = Transforms.ConvertToError(TextAnalyticsErrorInternal.DeserializeTextAnalyticsErrorInternal(errorElement)); message = error.Message; errorCode = error.ErrorCode.ToString(); } } catch (JsonException) { // Ignore any failures - unexpected content will be // included verbatim in the detailed error message } } }
partial void ExtractFailureContent( string?content, ref string?message, ref string?errorCode, #pragma warning disable CA1801 // Remove unused parameter ref IDictionary <string, string>?additionalInfo) #pragma warning restore CA1801 // Remove unused parameter #pragma warning restore CA1822 // Member can be static { if (!string.IsNullOrEmpty(content)) { try { // Try to parse the failure content and use that as the // default value for the message, error code, etc. using JsonDocument doc = JsonDocument.Parse(content); if (doc.RootElement.TryGetProperty("error", out JsonElement errorElement)) { TextAnalyticsError error = Transforms.ConvertToError(TextAnalyticsErrorInternal.DeserializeTextAnalyticsErrorInternal(errorElement)); message = error.Message; errorCode = error.ErrorCode.ToString(); } } catch (JsonException) { // Ignore any failures - unexpected content will be // included verbatim in the detailed error message } } }