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 } } }
internal static TextAnalyticsError ConvertToError(TextAnalyticsErrorInternal error) { string errorCode = error.Code; string message = error.Message; string target = error.Target; InnerError innerError = error.Innererror; if (innerError != null) { // Return the innermost error, which should be only one level down. return(new TextAnalyticsError(innerError.Code, innerError.Message, innerError.Target)); } return(new TextAnalyticsError(errorCode, message, target)); }
/// <summary> /// Action with an error. /// </summary> internal MultiCategoryClassifyActionResult(string actionName, DateTimeOffset completedOn, TextAnalyticsErrorInternal error) : base(actionName, completedOn, error) { }
internal AnalyzeSentimentActionResult(AnalyzeSentimentResultCollection result, DateTimeOffset completedOn, TextAnalyticsErrorInternal error) : base(completedOn, error) { Result = result; }
internal RecognizePiiEntitiesActionResult(RecognizePiiEntitiesResultCollection result, DateTimeOffset completedOn, TextAnalyticsErrorInternal error) : base(completedOn, error) { Result = result; }
/// <summary> /// Intended for mocking purposes only. /// </summary> internal AnalyzeSentimentActionResult(TextAnalyticsErrorInternal error) : base(error) { }
/// <summary> /// Action with an error. /// </summary> internal RecognizeLinkedEntitiesActionResult(string actionName, DateTimeOffset completedOn, TextAnalyticsErrorInternal error) : base(actionName, completedOn, error) { }
/// <summary> /// Intended for mocking purposes only. /// </summary> internal TextAnalyticsActionResult(TextAnalyticsErrorInternal error) { Error = Transforms.ConvertToError(error); }
internal ExtractKeyPhrasesActionResult(ExtractKeyPhrasesResultCollection result, DateTimeOffset completedOn, TextAnalyticsErrorInternal error) : base(completedOn, error) { Result = result; }
/// <summary> /// Intended for mocking purposes only. /// </summary> internal RecognizeEntitiesActionResult( TextAnalyticsErrorInternal error) : base(error) { }
/// <summary> /// Action with an error. /// </summary> internal ExtractSummaryActionResult(string actionName, DateTimeOffset completedOn, TextAnalyticsErrorInternal error) : base(actionName, completedOn, error) { }
/// <summary> /// Intended for mocking purposes only. /// </summary> internal ExtractKeyPhrasesActionResult(TextAnalyticsErrorInternal error) : base(error) { }
/// <summary> /// Action with an error. /// </summary> internal ExtractKeyPhrasesActionResult(DateTimeOffset completedOn, TextAnalyticsErrorInternal error) : base(completedOn, error) { }
/// <summary> /// Action with an error. /// </summary> internal AnalyzeSentimentActionResult(DateTimeOffset completedOn, TextAnalyticsErrorInternal error) : base(completedOn, error) { }
internal TextAnalyticsActionResult(DateTimeOffset completedOn, TextAnalyticsErrorInternal error) { CompletedOn = completedOn; Error = error != null?Transforms.ConvertToError(error) : default; }
internal RecognizeLinkedEntitiesActionResult(RecognizeLinkedEntitiesResultCollection result, DateTimeOffset completedOn, TextAnalyticsErrorInternal error) : base(completedOn, error) { _documentsResults = result; }
/// <summary> /// Action with an error. /// </summary> internal RecognizeEntitiesActionResult(DateTimeOffset completedOn, TextAnalyticsErrorInternal error) : base(completedOn, error) { }
/// <summary> /// Action with an error. /// </summary> internal AnalyzeSentimentActionResult(string actionName, DateTimeOffset completedOn, TextAnalyticsErrorInternal error) : base(actionName, completedOn, error) { }