~ knotless Search/
↑↓ move↵ open⇧↵ all results

geesawra.industries/old-fella

Old people's social media app

0
1
main
75 lines · 3.6 KB Raw History
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."
        }
    }
}