using System; using System.Collections.Generic; using Wino.Core.Domain.Entities.Shared; using Wino.Core.Domain.Enums; using Wino.Core.Domain.Interfaces; namespace Wino.Core.Domain.Models.Synchronization; /// /// Contains context information about a synchronizer error /// public class SynchronizerErrorContext { /// /// Account associated with the error /// public MailAccount Account { get; set; } /// /// Gets or sets the error code /// public int? ErrorCode { get; set; } /// /// Gets or sets the error message /// public string ErrorMessage { get; set; } /// /// Gets or sets the request bundle associated with the error /// public IRequestBundle RequestBundle { get; set; } /// /// Gets or sets additional data associated with the error /// public Dictionary AdditionalData { get; set; } = new Dictionary(); /// /// Gets or sets the exception associated with the error /// public Exception Exception { get; set; } /// /// Gets or sets the severity of the error for retry decision making. /// public SynchronizerErrorSeverity Severity { get; set; } = SynchronizerErrorSeverity.Fatal; /// /// Gets or sets the category of the error for targeted handling. /// public SynchronizerErrorCategory Category { get; set; } = SynchronizerErrorCategory.Unknown; /// /// Gets or sets the current retry attempt count. /// public int RetryCount { get; set; } /// /// Gets or sets the maximum number of retries allowed. /// public int MaxRetries { get; set; } = 3; /// /// Gets or sets the suggested delay before retrying. /// public TimeSpan? RetryDelay { get; set; } /// /// Gets or sets the folder ID associated with the error for partial failure tracking. /// public Guid? FolderId { get; set; } /// /// Gets or sets the folder name for display purposes. /// public string FolderName { get; set; } /// /// Gets or sets the type of operation that failed. /// Examples: "FolderSync", "MailSync", "RequestExecution", "Idle" /// public string OperationType { get; set; } /// /// Gets or sets whether the error was explicitly classified as a missing remote entity. /// This is used to distinguish true "mail/folder/event no longer exists" cases from /// unrelated HTTP 404 responses that should still surface to the user. /// public bool IsEntityNotFound { get; set; } /// /// Gets whether this error should be retried based on severity and retry count. /// public bool ShouldRetry => Severity == SynchronizerErrorSeverity.Transient && RetryCount < MaxRetries; /// /// Gets whether synchronization can continue despite this error. /// public bool CanContinueSync => Severity == SynchronizerErrorSeverity.Recoverable || (Severity == SynchronizerErrorSeverity.Transient && RetryCount >= MaxRetries); }