A WIP swift OAuth Library that one day I'll get back to
at main 44 lines 1.3 kB view raw
1// 2// File.swift 3// Gulliver 4// 5// Created by Bailey Townsend on 1/20/26. 6// 7 8import Foundation 9 10 11extension OAuthClientError: LocalizedError { 12 var errorDescription: String? { 13 switch self { 14 case .identifierParsingFailed: 15 return "Failed to parse the identifier as a did, handle, or PDS URL." 16 case .couldNotResolveADID: 17 return "Could not resolve a DID for the provided input. Is this a valid handle or DID?" 18 case .noPdsFound: 19 return "No PDS endpoint was found for the provided identifier." 20 case .unknownError(let error): 21 let error = error as NSError 22 let message = error.localizedDescription.isEmpty ? "An unknown error occurred." : error.localizedDescription 23 return message 24 case .webRequestError(let message): 25 return message 26 case .metaDatasError(let message): 27 return message ?? "An unknown error occurred trying to get or parse the metadata from the resource server." 28 case .catchAll(let message): 29 return message 30 } 31 } 32} 33 34 35enum OAuthClientError: Error { 36 case identifierParsingFailed 37 case couldNotResolveADID 38 case noPdsFound 39 case unknownError(Error) 40 case webRequestError(String) 41 case metaDatasError(String?) 42 case catchAll(String) 43 44}