@@ -34,7 +34,7 @@ def __init__(self, manager):
3434 def __str__ (self ):
3535 return "producer raised exception"
3636
37- class ReceiverFaults (Fault ):
37+ class ReceiverFault (Fault ):
3838 """
3939 Exception raised when Receivers cause an exception.
4040
@@ -725,23 +725,26 @@ def __exit__(self, typ, val, tb):
725725
726726 self .producer .__exit__ (typ , val , tb )
727727 except Exception as profail :
728+ # reference profail later.
728729 pass
729730
730731 # No receivers? It wasn't a success.
731732 if not self .receivers :
732- raise CopyFail (self , "no receivers" )
733+ raise CopyFail (self , "no receivers" , producer_fault = profail )
733734
734735 exit_faults = {}
735736 for x in self .receivers :
736737 try :
737738 x .__exit__ (typ , val , tb )
738739 except Exception as e :
739740 exit_faults [x ] = e
740- if exit_faults :
741- raise CopyFail (self , "could not exit all receivers" , exit_faults )
742741
743- if typ :
744- raise CopyFail (self , "exception occurred during COPY operation" )
742+ if typ or exit_faults or profail :
743+ raise CopyFail (self ,
744+ "could not complete the COPY operation" ,
745+ receiver_faults = exit_faults ,
746+ producer_fault = profail
747+ )
745748
746749 def reconcile (self , r ):
747750 """
@@ -789,7 +792,7 @@ def _service_receivers(self):
789792 # The CopyManager is eager to continue the operation.
790793 for x in faults :
791794 self .receivers .discard (x )
792- raise ReceiverFaults (self , faults )
795+ raise ReceiverFault (self , faults )
793796
794797 # Run the COPY to completion.
795798 def run (self ):
0 commit comments