 
 fileprivate extension DarwinCentral.PeripheralContinuationContext {
     
-    func didDisconnect() {
-        let error = CentralError.disconnected
+    func didDisconnect(_ error: Swift.Error? = nil) {
+        let error = error ?? CentralError.disconnected
+        // resume all pending operations
         while operations.isEmpty == false {
             operations.pop {
                 $0.operation.resume(throwing: error)
             }
         }
+        // end all notifications with disconnect error
         notificationStream.values.forEach {
             $0.finish(throwing: error)
         }

                assertionFailure("Missing context")
                return
            }
            context.didDisconnect()
            self.central.objectWillChange.send()
        }
        

        
        @objc(centralManager:didDisconnectPeripheral:error:)
        func centralManager(
            _ centralManager: CBCentralManager,
            didDisconnectPeripheral corePeripheral: CBPeripheral,
            error: Swift.Error?
        ) {
