1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import Foundation
import Security
struct ActionNotSentError: LocalizedError {
let underlying: Error
var errorDescription: String? { underlying.localizedDescription }
}
enum ServiceError: LocalizedError {
case invalidCredentials
case authFactorTokenRequired
case authFactorTokenRejected
case identityNotFound
case pdsNotFound
case invalidDID
case unsupportedDIDMethod
case noSession
case invalidSessionResponse
case invalidRecordResponse
case invalidUploadResponse
case invalidResponse
case notificationsUnavailable
case labelDefinitionsUnavailable
case invalidURL
case requestFailed(String)
case serverResponse(code: String, message: String)
case keychain(OSStatus)
case postReferenceUnavailable
case profileUnavailable
case tooManyImages
case postTextTooLong
case invalidImage
case imageTooLarge
case mixedMedia
case invalidVideo
case videoTooLarge
case videoUploadUnavailable
case videoProcessingFailed
case videoProcessingTimedOut
var errorDescription: String? {
switch self {
case .invalidCredentials: "Enter your Atmosphere account handle and password."
case .authFactorTokenRequired: "Enter the sign-in code sent to your email."
case .authFactorTokenRejected: "The sign-in code is not valid or has expired. Request a new code and try again."
case .identityNotFound: "Old Fella could not find an Atmosphere account for that handle."
case .pdsNotFound: "Old Fella could not find the account's personal data server."
case .invalidDID: "The account's decentralized identifier is invalid."
case .unsupportedDIDMethod: "This account uses an unsupported decentralized identifier."
case .noSession: "Your session is not available. Sign in again."
case .invalidSessionResponse: "The server returned an invalid sign-in response. Try again."
case .invalidRecordResponse: "Bluesky did not return the new post."
case .invalidUploadResponse: "Bluesky did not accept the image upload."
case .invalidResponse: "The server returned a response that Old Fella could not read."
case .notificationsUnavailable: "Notifications could not be loaded safely. Try again."
case .labelDefinitionsUnavailable: "Moderation settings could not be loaded. Try again."
case .invalidURL: "Old Fella could not create the Bluesky request."
case .requestFailed(let message): message
case .serverResponse(_, let message): message
case .keychain(let status): "Secure storage failed (\(status))."
case .postReferenceUnavailable: "This post is missing information needed for this action."
case .profileUnavailable: "The account profile could not be loaded."
case .tooManyImages: "Choose up to 10 images."
case .postTextTooLong: "The post is over 300 characters. Shorten the text and try again."
case .invalidImage: "Old Fella could not read this image. Choose another image."
case .imageTooLarge: "Each image must be smaller than 1 MB after compression."
case .mixedMedia: "Choose one video or up to 10 images."
case .invalidVideo: "Old Fella could not read this video. Choose another video."
case .videoTooLarge: "Choose a video smaller than 300 MB."
case .videoUploadUnavailable: "Video upload is not available. Try again."
case .videoProcessingFailed: "Bluesky could not process this video. Try another video."
case .videoProcessingTimedOut: "Bluesky took too long to process this video. Try again."
}
}
}