Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save raonivaladares/34c7b3884c04417108f336f2b4de58f8 to your computer and use it in GitHub Desktop.
Save raonivaladares/34c7b3884c04417108f336f2b4de58f8 to your computer and use it in GitHub Desktop.
func execute(with urlRquest: URLRequest) -> AnyPublisher<Data, NetworkPlataformError> {
return urlSession
.dataTaskPublisher(for: urlRquest)
.tryMap { data, response in
if let error = URLResponseErrorParser().parseErrorIfExists(on: response) {
throw error
}
return data
}
.mapError(NetworkPlataformErrorParser().parse)
.eraseToAnyPublisher()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment