diff options
author | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-04-03 10:54:51 +0200 |
---|---|---|
committer | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-04-03 13:31:10 +0200 |
commit | cbe7f8d49cb80e53948562c797c853b84f25c1e1 (patch) | |
tree | fe07a0c03e553d3fdb6e3a94514d88a36afa61dd /src/utils/uefi.py | |
parent | dfde363aa63ad3e7967da49f4ab599399b89e7f8 (diff) |
src: use explicit exception types in except Exception blocks
Capture only the relevant exception types in each except block.
The capture of the Exception type means hiding information for
unhandled error cases, even for syntax errors in the codebase.
Using a more fine grained exception filtering improves error
traceability.
Diffstat (limited to 'src/utils/uefi.py')
-rw-r--r-- | src/utils/uefi.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/utils/uefi.py b/src/utils/uefi.py index 17b35cb..0906ae9 100644 --- a/src/utils/uefi.py +++ b/src/utils/uefi.py @@ -139,12 +139,12 @@ def copy_windows_efi_bootloader(disk, partition): if os.path.exists(destination_dir): try: shutil.rmtree(destination_dir) - except Exception as e: + except OSError as e: raise OgError(f'Failed to delete {destination_dir}: {e}') from e logging.info(f'Copying {loader_dir} into {destination_dir}') try: shutil.copytree(loader_dir, destination_dir) - except Exception as e: + except OSError as e: raise OgError(f'Failed to copy {loader_dir} into {destination_dir}: {e}') from e finally: umount(mountpoint) |