diff --git a/Mlem/App/Globals/Definitions/ErrorsTracker.swift b/Mlem/App/Globals/Definitions/ErrorsTracker.swift index d2034354f..aff344a28 100644 --- a/Mlem/App/Globals/Definitions/ErrorsTracker.swift +++ b/Mlem/App/Globals/Definitions/ErrorsTracker.swift @@ -22,7 +22,7 @@ class ErrorsTracker { var ret = "" for details in errors { - ret += "\(details.when.formatted(.iso8601))\t\(details.title ?? "Error")\t\(details.errorText)\n" + ret += "\(details.when.formatted(.iso8601))\t\(details.title ?? "Error")\t\(details.errorText())\n" } return ret diff --git a/Mlem/App/Models/ErrorDetails.swift b/Mlem/App/Models/ErrorDetails.swift index 934bd0b90..5c3526a7b 100644 --- a/Mlem/App/Models/ErrorDetails.swift +++ b/Mlem/App/Models/ErrorDetails.swift @@ -66,9 +66,9 @@ struct ErrorDetails: Hashable { lhs.hashValue == rhs.hashValue } - var errorText: String { + func errorText(includingLocation: Bool = true) -> String { var output = String(describing: error) - if let location { + if includingLocation, let location { output += " (\(location))" } for account in AccountsTracker.main.userAccounts { diff --git a/Mlem/App/Views/Root/Tabs/Settings/ErrorLogView.swift b/Mlem/App/Views/Root/Tabs/Settings/ErrorLogView.swift index e15bba746..0cfb7ce9c 100644 --- a/Mlem/App/Views/Root/Tabs/Settings/ErrorLogView.swift +++ b/Mlem/App/Views/Root/Tabs/Settings/ErrorLogView.swift @@ -59,7 +59,7 @@ struct ErrorLogView: View { Spacer() Button { - UIPasteboard.general.string = details.errorText + UIPasteboard.general.string = details.errorText() ToastModel.main.add(.success(String("Copied"))) } label: { Text(Image(systemName: Icons.copy)) @@ -68,7 +68,7 @@ struct ErrorLogView: View { } } - Text(String(describing: details.error)) + Text(details.errorText(includingLocation: false)) if let location = details.location { HStack(alignment: .top, spacing: 2) { diff --git a/Mlem/App/Views/Shared/ErrorView.swift b/Mlem/App/Views/Shared/ErrorView.swift index 34f8169e3..15077a199 100644 --- a/Mlem/App/Views/Shared/ErrorView.swift +++ b/Mlem/App/Views/Shared/ErrorView.swift @@ -29,7 +29,7 @@ struct ErrorView: View { var body: some View { VStack(spacing: 15) { if showingFullError { - errorDetails(errorDetails.errorText) + errorDetails(errorDetails.errorText()) } else { if let systemImage = errorDetails.systemImage { Image(systemName: systemImage) diff --git a/Mlem/App/Views/Shared/Toast/ToastView.swift b/Mlem/App/Views/Shared/Toast/ToastView.swift index fe0d3df15..5fa341184 100644 --- a/Mlem/App/Views/Shared/Toast/ToastView.swift +++ b/Mlem/App/Views/Shared/Toast/ToastView.swift @@ -160,7 +160,7 @@ struct ToastView: View { VStack(alignment: .leading, spacing: 0) { if isExpanded { ScrollView { - Text(details.errorText) + Text(details.errorText()) .foregroundStyle(.red) .padding(8) .multilineTextAlignment(.leading) @@ -168,7 +168,7 @@ struct ToastView: View { .frame(maxWidth: .infinity) Button("Copy", systemImage: Icons.copy) { - UIPasteboard.general.string = details.errorText + UIPasteboard.general.string = details.errorText() } .font(.caption) .buttonStyle(.borderedProminent)