In
|
private func handleFlagsError(_ error: any Error, completion: @Sendable @escaping (Result<[Flag], any Error>) -> Void) { |
|
if defaultFlags.isEmpty { |
|
completion(.failure(error)) |
|
} else { |
|
completion(.success(defaultFlags)) |
|
} |
|
} |
we could add some code to return the cached flags in the case of a fetch error.
I think we need to determine why we got to the point where we got the error in the first place if the cache is valid. Surely we would have already have returned the cached values?
Let's add some tests to cover the API error scenarios and ensure that either we're returning cached values anyway, or we need to fall back to the cache in handleFlagsError()