@@ -1205,9 +1205,23 @@ def copy_to_gdg(self, src, dest):
1205
1205
# If identical_gdg_copy is False, use the default next generation
1206
1206
dest_gen_name = f"{ dest } (+1)"
1207
1207
# Perform the copy operation
1208
- rc = datasets .copy (gds .name , dest_gen_name , ** copy_args )
1209
- if rc != 0 :
1210
- success = False
1208
+
1209
+ try :
1210
+ result = datasets .copy (gds .name , dest_gen_name , ** copy_args )
1211
+ rc = result .rc if hasattr (result , 'rc' ) else result
1212
+ if rc != 0 :
1213
+ success = False
1214
+ except zoau_exceptions .ZOAUException as e :
1215
+ stderr = getattr (e .response , 'stderr_response' , str (e ))
1216
+ if "BGYSC0514E" in stderr :
1217
+ raise GenerationDataGroupCreateError (
1218
+ msg = (
1219
+ "BGYSC0514E An error occurred while attempting to define the file."
1220
+ " This might be because the GDS part of the src GDG is being used by another process."
1221
+ )
1222
+ ) from e
1223
+ else :
1224
+ raise GenerationDataGroupCreateError (msg = f"GDG creation failed. Raw error: { stderr } " ) from e
1211
1225
return success
1212
1226
1213
1227
def _copy_tree (self , entries , src , dest , dirs_exist_ok = False ):
@@ -4357,5 +4371,12 @@ def __init__(
4357
4371
super ().__init__ (msg )
4358
4372
4359
4373
4374
+ class GenerationDataGroupCreateError (Exception ):
4375
+ def __init__ (self , msg ):
4376
+ """Error during copy of a Generation Data Group."""
4377
+ self .msg = msg
4378
+ super ().__init__ (self .msg )
4379
+
4380
+
4360
4381
if __name__ == "__main__" :
4361
4382
main ()
0 commit comments