Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix token not being redacted from error log #1792

Merged
merged 2 commits into from
Feb 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Mlem/App/Globals/Definitions/ErrorsTracker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Mlem/App/Models/ErrorDetails.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions Mlem/App/Views/Root/Tabs/Settings/ErrorLogView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion Mlem/App/Views/Shared/ErrorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions Mlem/App/Views/Shared/Toast/ToastView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,15 @@ struct ToastView: View {
VStack(alignment: .leading, spacing: 0) {
if isExpanded {
ScrollView {
Text(details.errorText)
Text(details.errorText())
.foregroundStyle(.red)
.padding(8)
.multilineTextAlignment(.leading)
}
.frame(maxWidth: .infinity)

Button("Copy", systemImage: Icons.copy) {
UIPasteboard.general.string = details.errorText
UIPasteboard.general.string = details.errorText()
}
.font(.caption)
.buttonStyle(.borderedProminent)
Expand Down