diff --git a/Sources/Confidence/Apply/FlagApplierWithRetries.swift b/Sources/Confidence/Apply/FlagApplierWithRetries.swift index ca652ecf..f9bada99 100644 --- a/Sources/Confidence/Apply/FlagApplierWithRetries.swift +++ b/Sources/Confidence/Apply/FlagApplierWithRetries.swift @@ -154,15 +154,8 @@ final class FlagApplierWithRetries: FlagApplier { } private func logApplyError(error: Error) { - switch error { - case ConfidenceError.applyStatusTransitionError, ConfidenceError.cachedValueExpired, - ConfidenceError.flagNotFoundInCache: - Logger(subsystem: "com.confidence.provider", category: "apply").debug( - "Cache data for flag was updated while executing \"apply\", aborting") - default: - Logger(subsystem: "com.confidence.provider", category: "apply").error( - "Error while executing \"apply\": \(error)") - } + Logger(subsystem: "com.confidence.provider", category: "apply").error( + "Error while executing \"apply\": \(error)") } } diff --git a/Sources/Confidence/ConfidenceError.swift b/Sources/Confidence/ConfidenceError.swift index 6dee3c3a..031c21ce 100644 --- a/Sources/Confidence/ConfidenceError.swift +++ b/Sources/Confidence/ConfidenceError.swift @@ -1,55 +1,27 @@ import Foundation public enum ConfidenceError: Error, Equatable { - /// Signifies that the provider is not connected to the Confidence backend - case providerNotConnected - /// GRPC-specific error during the connection case grpcError(message: String) - /// Error while caching a resolve or retrieving a cached resolve case cacheError(message: String) - /// Corrupted cache file case corruptedCache(message: String) - /// Flag not found in cache - case flagNotFoundInCache case flagNotFoundError(key: String) - /// Value in cache expired - case cachedValueExpired - /// Apply state transition not allowed - case applyStatusTransitionError - /// No resolveToken returned by the server - case noResolveTokenFromServer - /// No resolveToken in the cache - case noResolveTokenFromCache - /// Bad request from provider case badRequest(message: String?) - /// Internal error case internalError(message: String) case parseError(message: String) - case invalidContextError case invalidContextInMessage } extension ConfidenceError: CustomStringConvertible { public var description: String { switch self { - case .providerNotConnected: - return "The provider is not connected" case .grpcError(let message): return message case .cacheError(let message): return message case .corruptedCache(let message): return message - case .flagNotFoundInCache: - return "Flag not found in the cache" - case .cachedValueExpired: - return "Cached flag has an old evaluation context" - case .applyStatusTransitionError: - return "Apply status transition error" - case .noResolveTokenFromServer: - return "No resolver token returned by the server" - case .noResolveTokenFromCache: - return "No resolver token in cache, cache needs refresh" + case .flagNotFoundError(let key): + return "Flag not found for key \(key)" case .badRequest(let message): guard let message = message else { return "Bad request from provider" @@ -59,10 +31,6 @@ extension ConfidenceError: CustomStringConvertible { return "An internal error occurred: \(message)" case .parseError(let message): return "Parse error occurred: \(message)" - case .flagNotFoundError(let key): - return "Flag not found for key \(key)" - case .invalidContextError: - return "Invalid context error" case .invalidContextInMessage: return "Field 'context' is not allowed in event's data" } diff --git a/Sources/Confidence/Http/HttpClient.swift b/Sources/Confidence/Http/HttpClient.swift index 40f2f1f8..4d9b0c18 100644 --- a/Sources/Confidence/Http/HttpClient.swift +++ b/Sources/Confidence/Http/HttpClient.swift @@ -40,7 +40,7 @@ extension HTTPURLResponse { switch self.status { case .notFound, .badRequest: - return ConfidenceError.badRequest(message: error?.message ?? "") + return ConfidenceError.badRequest(message: error?.message) default: return defaultError } diff --git a/Sources/Confidence/HttpStatusCode+Error.swift b/Sources/Confidence/HttpStatusCode+Error.swift index ed3c2257..4e2385ff 100644 --- a/Sources/Confidence/HttpStatusCode+Error.swift +++ b/Sources/Confidence/HttpStatusCode+Error.swift @@ -9,7 +9,7 @@ extension HTTPURLResponse { case .notFound: return ConfidenceError.flagNotFoundError(key: flag) case .badRequest: - return ConfidenceError.badRequest(message: error?.message ?? "") + return ConfidenceError.badRequest(message: error?.message) default: return defaultError }