internal static AnnotationResultSummary GetResultSummaryFromSuccessInvocation(MemoryStream payload) { var annotationResult = JsonUtilities.Deserialize <AnnotationResult>(payload); string errorMessage = annotationResult.errorCategory == null ? null : annotationResult.status; return(AnnotationResultSummary.Create(annotationResult, annotationResult.errorCategory, errorMessage)); }
internal AnnotationResultSummary GetResultSummaryFromFailedInvocation(Exception e) { var additionalDescription = ""; if (ExceptionUtilities.HasException <TaskCanceledException>(e)) { _errorCategory = ErrorCategory.TimeOutError; additionalDescription = $" Annotation job was not finished in {_annotationTimeOut} milliseconds."; } if (_errorCategory == null) { _errorCategory = ExceptionUtilities.ExceptionToErrorCategory(e); } e = ExceptionUtilities.GetInnermostException(e); string errorMessage = $"Failed job when invoking the annotation job: {e.Message}.{additionalDescription}"; return(AnnotationResultSummary.Create(null, _errorCategory, errorMessage)); }
private static (ErrorCategory?, string) GetMostSevereErrorCategoryAndMessage(IEnumerable <AnnotationResultSummary> annotationResultSummaries) { List <(AnnotationResultSummary Item, int Index)> failedJobs = annotationResultSummaries .Select(x => x ?? AnnotationResultSummary.Create(null, ErrorCategory.NirvanaError, "No result summary available for the annotation job.")) .Select((x, i) => (Item: x, Index: i)).Where(x => x.Item.ErrorCategory != null).ToList(); if (failedJobs.Count == 0) { return(null, null); } Logger.WriteLine(AnnotationLambdaFailedStatus); failedJobs.ForEach(x => Logger.WriteLine($"Job {x.Index + 1}: {x.Item.ErrorCategory} {x.Item.ErrorMessage}")); ErrorCategory?mostSevereError = failedJobs.Select(x => x.Item.ErrorCategory).Min(); string errorMessage = mostSevereError == ErrorCategory.UserError ? string.Join(";", failedJobs.Where(x => x.Item.ErrorCategory == mostSevereError).Select(x => x.Item.ErrorMessage).Distinct()) : ""; return(mostSevereError, errorMessage); }