fix(app): keep the editor's own save errors and gate an unread archive

- Editor: a failed save showed what the server or the archive layer would say
  for the exception's type, so the editor's own sentences were lost: frames
  changed on the server or settings changed elsewhere read "The server does not
  answer", a read-only account or a gone sequence "Something went wrong". These
  failures are now EditorException (an IOException; ProxiesOutdatedException
  derives from it) and the toast shows their sentence as it is. A project
  written by a newer Titano is reported with the same sentence as a corrupt one
  instead of the parser's English text.
- Library: a job posted to a server whose certificate changed since sign-in
  threw out of the action unreported; the pin's refusal now reaches the error
  toast ("The certificate was not trusted").
- Archive: picking another archive forced it offline until it was read, so the
  rebuild dialog called it offline with the previous archive's count, and
  disabled commands said the archive must be online. What was read is now kept
  apart from availability: until the picked archive is read, Rebuild and the
  online commands wait and say so, health fixes and search results of the
  previous archive are cleared, and a running search is cancelled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-12 11:09:04 +00:00
1 parent d47e3e9b49
commit 4850af2443
15 files changed
+218 -31

No files matched your search

@@ -145,7 +145,7 @@ public sealed class RemoteSequenceSource : ISequenceSource
var merged = changedThere ? ProjectMerge.Merge(basis, project, stored) : project;
if (ProjectMerge.SameValues(merged, stored)) return merged;
if (IsOutdated) throw new ProxiesOutdatedException(Loc.L("Editor.Error.FramesChanged"));
if (_noEditRight) throw new InvalidOperationException(Loc.L("Editor.Error.RemoteReadOnly"));
if (_noEditRight) throw new EditorException(Loc.L("Editor.Error.RemoteReadOnly"));
if (changedThere && ProjectMerge.Conflicts(basis, project, stored) is { Count: > 0 } conflicts)
throw new ProjectConflictException(Loc.L("Editor.Error.SaveConflict"), stored, conflicts);
var hero = merged.HeroFrame == stored.HeroFrame ? (Guid?)null : HeroFrameId(merged);
@@ -159,7 +159,7 @@ public sealed class RemoteSequenceSource : ISequenceSource
catch (TitanoApiException ex) when (ex.Status == HttpStatusCode.Conflict)
{
// Changed on the server since this editor read it: merge again on top of the server's settings.
if (attempt == SaveAttempts) throw new IOException(Loc.L("Editor.Error.SaveConflict"), ex);
if (attempt == SaveAttempts) throw new EditorException(Loc.L("Editor.Error.SaveConflict"), ex);
var manifest = await Call(() => _api.GetManifestAsync(Id, cancellationToken));
if (!SameFrames(manifest)) throw Outdated();
Volatile.Write(ref _stored, new Stored(Parse(manifest.SettingsJson), manifest.SettingsVersion));
@@ -359,7 +359,7 @@ public sealed class RemoteSequenceSource : ISequenceSource
private Guid HeroFrameId(ProjectSettings project) =>
project.HeroFrame is { } hero && (uint)hero < (uint)_remote.Frames.Count ? _remote.Frames[hero].Id : Guid.Empty;
/// <exception cref="InvalidDataException">The settings are not a project or come from a newer Titano.</exception>
/// <exception cref="EditorException">The settings are not a project or come from a newer Titano.</exception>
private static ProjectSettings Parse(string? json)
{
if (string.IsNullOrWhiteSpace(json)) return new ProjectSettings();
@@ -367,9 +367,9 @@ public sealed class RemoteSequenceSource : ISequenceSource
{
return ProjectSettings.FromJson(json);
}
catch (JsonException ex)
catch (Exception ex) when (ex is JsonException or InvalidDataException)
{
throw new InvalidDataException(Loc.L("Editor.Error.Project"), ex);
throw new EditorException(Loc.L("Editor.Error.Project"), ex);
}
}
@@ -398,7 +398,7 @@ public sealed class RemoteSequenceSource : ISequenceSource
}
catch (TitanoApiException ex) when (ex.Status == HttpStatusCode.NotFound)
{
throw new InvalidOperationException(Loc.L("Editor.Error.Missing"), ex);
throw new EditorException(Loc.L("Editor.Error.Missing"), ex);
}
}
@@ -423,4 +423,4 @@ public sealed class ProjectConflictException(string message, ProjectSettings ser
/// The proxies of a server sequence are for frames the server no longer has (added or removed since they were fetched):
/// they must be fetched again before the sequence can be edited.
/// </summary>
public sealed class ProxiesOutdatedException(string message) : IOException(message);
public sealed class ProxiesOutdatedException(string message) : EditorException(message);