Skip to content

Commit c822f51

Browse files
committed
add error handling
1 parent 912bef4 commit c822f51

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

sync.py

+13-10
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,20 @@ def copyFiles(src: str, destination: str, exceptions: list[str]):
105105
# wait
106106
time.sleep(0.1)
107107

108+
# for later
109+
message = ""
110+
108111
# sync files
109112
for destination in destinations:
110-
copyFiles(
111-
syncFolder,
112-
destination,
113-
exceptions
114-
)
113+
try:
114+
copyFiles(
115+
syncFolder,
116+
destination,
117+
exceptions
118+
)
119+
except Exception as e:
120+
msg = f"Failed to sync due to \"{str(e)}\""
115121

116122
# print message
117-
print("\n".join([
118-
"===============",
119-
f"Synced '{os.path.abspath(syncFolder)}' to:\n{listToBulletList([os.path.abspath(destination) for destination in destinations])}",
120-
"==============="
121-
]))
123+
msg = f"Synced '{os.path.abspath(syncFolder)}' to:\n{listToBulletList([os.path.abspath(destination) for destination in destinations])}"
124+
print(msg, end = "\n\n")

0 commit comments

Comments
 (0)