From 0b7203a0cf19019b67ee0282e5352e25d18fca54 Mon Sep 17 00:00:00 2001 From: Michael Skogberg Date: Sun, 24 Nov 2024 19:40:13 +0200 Subject: [PATCH] Fix error message rendering --- MusicPimp/LibraryList.swift | 5 ++++- MusicPimp/PimpViews.swift | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/MusicPimp/LibraryList.swift b/MusicPimp/LibraryList.swift index 7eeb0e9..2b54057 100644 --- a/MusicPimp/LibraryList.swift +++ b/MusicPimp/LibraryList.swift @@ -26,7 +26,10 @@ struct LibraryListInternal: View where T: LibraryVMLike, D: DownloaderLike .task { switch vm.appearAction { case .Reload: - await vm.load() + // Sometimes this .task is triggered twice, cancelling the previous one inadvertently, so as a workaround, load in a detached task + Task { + await vm.load() + } case .Dismiss: dismiss() case .Noop: diff --git a/MusicPimp/PimpViews.swift b/MusicPimp/PimpViews.swift index d56b9ee..8740074 100644 --- a/MusicPimp/PimpViews.swift +++ b/MusicPimp/PimpViews.swift @@ -67,6 +67,11 @@ func outcomeView(outcome: Outcome, @ViewBuilder render: (T) -> A) -> so case .Loaded(let t): render(t) case .Err(let error): - fullSizeText("Error. \(error)") + let message = switch error { + case let err as PimpError: err.message + case _ as URLError: "A network error occurred." + default: "An error occurred." + } + fullSizeText(message) } }