using Chronos.App.Infrastructure; using Chronos.Core.Archiving; using Chronos.Core.Localization; using Chronos.Data; using Chronos.Data.Archiving; namespace Chronos.App.Archiving; /// /// Why an Archive screen action stopped, as one localized sentence chosen by cause (BRIEF ยง0.2 rule 6). The /// exception's own text, which may be technical or unlocalized, goes to the tooltip and the log only. /// public static class ArchiveFailures { public static string Cause(Exception ex) => ex switch { ArchiveOfflineException offline => Loc.L(offline.Availability == ArchiveAvailability.ReadOnly ? "Archive.Error.ReadOnly" : "Archive.Error.Offline", Formatting.LeftToRight(offline.Root)), // Already one localized sentence each; TrashMismatchException is a trash entry none of whose files matches its record // any more (FrameTrash.RestoreAsync). Other IOExceptions and InvalidDataExceptions (a sidecar of another sequence) // carry technical text. LeaseUnavailableException or NewerFormatException or StaleRenamePlanException or NestedRenameException or StaleDeletePlanException or SequenceInLibraryException or TrashMismatchException or Core.Project.ProjectTooLargeException or ArchiveStructureException => ex.Message, UnauthorizedAccessException => Loc.L("Archive.Failed.Access"), DatabaseException => Loc.L("Archive.Failed.Index"), ArgumentException => Loc.L("Archive.Failed.Gone"), _ => Loc.L("Archive.Failed.Files"), }; }