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

                
                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:

                
                switch event {
                case .Next(let response):
                    observer.onNextOrError { try response.mapArray(rootKey) }
                case .Error(let error):
                    observer.onError(error)
                case .Completed:
