Last active
March 9, 2020 00:37
-
-
Save raonivaladares/34c7b3884c04417108f336f2b4de58f8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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