···1+//
2+// ErrorHandling.swift
3+// shortcut
4+//
5+// Created by Bailey Townsend on 6/29/25.
6+//
7+import Foundation
8+9+enum GenericIntentError: Error, CustomLocalizedStringResourceConvertible, LocalizedError {
10+ case general
11+ case message(_ message: String)
12+ case notFound(_ lostItem: String)
13+14+ var localizedStringResource: LocalizedStringResource {
15+ switch self {
16+ case let .message(message): return "\(message)"
17+ case .general: return "There was an error making the post."
18+ case let .notFound(lostItem): return "\(lostItem) could not be found"
19+ }
20+ }
21+}
+40
AtProtoBackup/JSONResponseSection.swift
···0000000000000000000000000000000000000000
···1+//
2+// JSONResponseSection.swift
3+// AtProtoBackup
4+//
5+// Created by Corey Alexander on 8/25/25.
6+//
7+8+import SwiftUI
9+10+struct JSONResponseSection: View {
11+ let jsonData: Data?
12+13+ var body: some View {
14+ if let jsonData = jsonData {
15+ VStack(alignment: .leading, spacing: 8) {
16+ Text("JSON Response:")
17+ .font(.headline)
18+19+ ScrollView {
20+ if let jsonObject = try? JSONSerialization.jsonObject(with: jsonData),
21+ let prettyData = try? JSONSerialization.data(withJSONObject: jsonObject, options: [.prettyPrinted]),
22+ let prettyString = String(data: prettyData, encoding: .utf8) {
23+ Text(prettyString)
24+ .font(.system(.body, design: .monospaced))
25+ .textSelection(.enabled)
26+ .padding()
27+ .background(Color.gray.opacity(0.1))
28+ .cornerRadius(8)
29+ } else {
30+ Text("Unable to decode JSON data")
31+ .foregroundColor(.secondary)
32+ }
33+ }
34+ }
35+ } else {
36+ Text("No JSON response available")
37+ .foregroundColor(.secondary)
38+ }
39+ }
40+}