@@ -96,24 +96,31 @@ def create_directory_if_not_exists(directory_path: Path):
96
96
# Check if the directory already exists
97
97
if not os .path .exists (directory_path ):
98
98
# Create the directory
99
- os .makedirs (directory_path )
100
- log ("debug" , f"Created directory: { directory_path } " )
99
+ try :
100
+ os .makedirs (directory_path )
101
+ log ("debug" , f"Created directory: { directory_path } " )
102
+ except Exception as e :
103
+ log ("error" , f"Could not create direction { directory_path } . { e } " )
101
104
102
105
103
106
def create_or_empty_directory (directory_path : Path ):
104
107
# Check if the directory already exists
105
108
if os .path .exists (directory_path ):
106
109
# Empty the directory by removing all its contents
107
110
shutil .rmtree (directory_path )
108
- os .makedirs (directory_path )
109
- log (
110
- "debug" ,
111
- f"Emptied and re-created directory: { directory_path } " ,
112
- )
111
+
112
+ try :
113
+ os .makedirs (directory_path )
114
+ log ("debug" , f"Emptied and re-created directory: { directory_path } " )
115
+ except Exception as e :
116
+ log ("error" , f"Could not create direction { directory_path } . { e } " )
113
117
else :
114
118
# Create the directory if it does not exist
115
- os .makedirs (directory_path )
116
- log ("debug" , f"Created directory: { directory_path } " )
119
+ try :
120
+ os .makedirs (directory_path )
121
+ log ("debug" , f"Created directory: { directory_path } " )
122
+ except Exception as e :
123
+ log ("error" , f"Could not create direction { directory_path } . { e } " )
117
124
118
125
119
126
# TODO: Add better handling for multiple build info files
0 commit comments