Skip to content

Commit

Permalink
[session] log after tryCatch (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjechris authored May 22, 2022
1 parent 06b560c commit 9e6a06c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Sources/SimpleHTTP/Session/Session.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@ public class Session {

extension Session {
private func dataPublisher<Output>(for request: Request<Output>) -> AnyPublisher<Response<Output>, Error> {
let adaptedRequest = config.interceptor.adaptRequest(request)
let modifiedRequest = config.interceptor.adaptRequest(request)

do {
let urlRequest = try adaptedRequest
let urlRequest = try modifiedRequest
.toURLRequest(encoder: config.encoder, relativeTo: baseURL, accepting: config.decoder)

return urlRequestPublisher(urlRequest)
.validate(config.errorConverter)
.map { Response(data: $0.data, request: adaptedRequest) }
.handleEvents(receiveCompletion: { self.logIfFailure($0, for: adaptedRequest) })
.map { Response(data: $0.data, request: modifiedRequest) }
.tryCatch { try self.rescue(error: $0, request: request) }
.handleEvents(receiveCompletion: { self.logIfFailure($0, for: modifiedRequest) })
.eraseToAnyPublisher()
}
catch {
Expand Down

0 comments on commit 9e6a06c

Please sign in to comment.