diff --git a/Sources/PinboardKit/API/PinboardAPI.swift b/Sources/PinboardKit/API/PinboardAPI.swift index c92c36f..064f407 100644 --- a/Sources/PinboardKit/API/PinboardAPI.swift +++ b/Sources/PinboardKit/API/PinboardAPI.swift @@ -33,6 +33,8 @@ public struct PinboardAPI { return .loading case .finishedLoading: return .finishedLoading + case .errorLoading: + return .errorLoading } } .eraseToAnyPublisher() diff --git a/Sources/PinboardKit/API/PinboardAPIEvent.swift b/Sources/PinboardKit/API/PinboardAPIEvent.swift index 157df60..759ac5d 100644 --- a/Sources/PinboardKit/API/PinboardAPIEvent.swift +++ b/Sources/PinboardKit/API/PinboardAPIEvent.swift @@ -3,4 +3,5 @@ import Foundation public enum PinboardAPIEvent { case loading case finishedLoading + case errorLoading } diff --git a/Sources/PinboardKit/NetworkClient/PinboardClient.swift b/Sources/PinboardKit/NetworkClient/PinboardClient.swift index 34c77ee..94526e3 100644 --- a/Sources/PinboardKit/NetworkClient/PinboardClient.swift +++ b/Sources/PinboardKit/NetworkClient/PinboardClient.swift @@ -53,6 +53,10 @@ struct PinboardClient { response: result.response ) } + .mapError{ error -> Error in + eventSubject.send(.errorLoading) + return error + } .receive(on: DispatchQueue.main) .eraseToAnyPublisher() } diff --git a/Sources/PinboardKit/NetworkClient/PinboardClientEvent.swift b/Sources/PinboardKit/NetworkClient/PinboardClientEvent.swift index 9956ad7..c0165f1 100644 --- a/Sources/PinboardKit/NetworkClient/PinboardClientEvent.swift +++ b/Sources/PinboardKit/NetworkClient/PinboardClientEvent.swift @@ -3,4 +3,5 @@ import Foundation enum PinboardClientEvent { case loading case finishedLoading + case errorLoading }