                 
                 switch event {
                 case .Next(let response):
-                    do {
-                        let mappedObject:[T] = try response.mapArray(rootKey)
-                        observer.onNext(mappedObject)
-                    } catch {
-                        observer.onError(error)
-                    }
+                    observer.onNextOrError { try response.mapArray(rootKey) }
                 case .Error(let error):
                     observer.onError(error)
                 case .Completed:

                
                switch event {
                case .Next(let response):
                    do {
                        let mappedObject:T = try response.mapObject(rootKey)
                        observer.onNext(mappedObject)
                    } catch {
                        observer.onError(error)
                    }
                case .Error(let error):
                    observer.onError(error)
                case .Completed:

    }

}

private extension AnyObserver {
    
    private func onNextOrError(function: () throws -> Element) {
        do {
            let value = try function()
            self.onNext(value)
        } catch {
            self.onError(error)
        }
    }
}
