pw_build: Fix exception handling in mirror_tree When linking fails, we fall back to copying. This always fails because the original reception is re-raised even if the copy succeeds. Just remove the exception management in the copy case. If copying fails, we'll get both exceptions reported in a chain. No-Docs-Update-Reason: bug fix Change-Id: I49f0b381ba0e607f46725d1cd59bb16b811c7cf2 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/48700 Commit-Queue: Michael Spang <spang@google.com> Reviewed-by: Rob Mohr <mohrr@google.com>
diff --git a/pw_build/py/pw_build/mirror_tree.py b/pw_build/py/pw_build/mirror_tree.py index a1a74b2..46d19a0 100644 --- a/pw_build/py/pw_build/mirror_tree.py +++ b/pw_build/py/pw_build/mirror_tree.py
@@ -63,12 +63,8 @@ # If the link failed try copying. If copying fails re-raise the # original exception. except OSError: - try: - shutil.copy(source, dest) - yield dest - except OSError: - pass - raise + shutil.copy(source, dest) + yield dest def _link_files_or_dirs(paths: Iterable[Path],