diff --git a/Sources/SwiftyLiveApi/LiveApiClient.swift b/Sources/SwiftyLiveApi/LiveApiClient.swift index 1662205..2b28230 100644 --- a/Sources/SwiftyLiveApi/LiveApiClient.swift +++ b/Sources/SwiftyLiveApi/LiveApiClient.swift @@ -435,16 +435,6 @@ public class LiveApiClient { static let oceanicTracks = "/public/v2/tracks" } - - //MARK: Custom errors - public enum LiveApiClientError: String, Error { - case requestLimitReached = "Reached request limit" - case dataIsNil = "Data returned nil" - case tooManyUsers = "Request contained too much items (25 items max)" - case failedToEncodeRequestBody = "Failed to encode request body" - case emptyrequestParameters = "All of the request parameters were empty" - case invalidUrl = "Request URL is invalid" - } } ///enum that contains ```sessionId```s of servers for your convenience. Automatically fills when ```getSessions``` is called without errors, but can also be filled manually using ```updateSessionIds(sessions: [Session])```. diff --git a/Sources/SwiftyLiveApi/LiveApiJsonTypes.swift b/Sources/SwiftyLiveApi/LiveApiJsonTypes.swift index 573e1b9..ef37dcc 100644 --- a/Sources/SwiftyLiveApi/LiveApiJsonTypes.swift +++ b/Sources/SwiftyLiveApi/LiveApiJsonTypes.swift @@ -490,23 +490,28 @@ public enum GradeState: Int { case warning = 2 } -//MARK: Error Code types - -public enum LiveApiError: Int, Error { - case ok = 0 - case userNotFound = 1 - case missingRequestParameters = 2 - case endpointError = 3 - case notAuthorized = 4 - case serverNotFound = 5 - case flightNotFound = 6 - case noAtisAvailable = 7 - - // Error just in case - case unknownErrorCode = 404 +//MARK: LiveAPI error + +@available(*, deprecated, renamed: "LiveApiClient.LiveApiError") +typealias LiveApiError = LiveApiClient.LiveApiError + +extension LiveApiClient { + public enum LiveApiError: Int, Error { + case ok = 0 + case userNotFound = 1 + case missingRequestParameters = 2 + case endpointError = 3 + case notAuthorized = 4 + case serverNotFound = 5 + case flightNotFound = 6 + case noAtisAvailable = 7 + + // Error just in case + case unknownErrorCode = 404 + } } -extension LiveApiError: LocalizedError { +extension LiveApiClient.LiveApiError: LocalizedError { public var errorDescription: String? { switch self { case .ok: @@ -530,3 +535,34 @@ extension LiveApiError: LocalizedError { } } } + +//MARK: Client errors +extension LiveApiClient { + public enum LiveApiClientError: String, Error { + case requestLimitReached = "Reached request limit" + case dataIsNil = "Data returned nil" + case tooManyUsers = "Request contained too much items (25 items max)" + case failedToEncodeRequestBody = "Failed to encode request body" + case emptyrequestParameters = "All of the request parameters were empty" + case invalidUrl = "Request URL is invalid" + } +} + +extension LiveApiClient.LiveApiClientError: LocalizedError { + public var errorDescription: String? { + switch self { + case .dataIsNil: + return "Data returned nil" + case .requestLimitReached: + return "Request limit reached" + case .tooManyUsers: + return "Too many users (max 25)" + case .failedToEncodeRequestBody: + return "Failed to encode request body" + case .emptyrequestParameters: + return "All request parameters are empty" + case .invalidUrl: + return "Request URL is invalid" + } + } +}