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/live | |
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/live')
-rw-r--r-- | src/live/ogOperations.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/live/ogOperations.py b/src/live/ogOperations.py index 0c08459..02af011 100644 --- a/src/live/ogOperations.py +++ b/src/live/ogOperations.py @@ -52,7 +52,7 @@ class OgLiveOperations: try: proc = subprocess.call(["pkill", "-9", "browser"]) proc = subprocess.Popen(["browser", "-qws", url]) - except Exception as e: + except OSError as e: raise OgError('Cannot restart browser') from e def _refresh_payload_disk(self, cxt, part_setup, num_disk): @@ -144,7 +144,7 @@ class OgLiveOperations: try: r = shutil.copy(src, dst) tip_write_csum(image_name) - except Exception as e: + except (OSError, OgError) as e: raise OgError(f'Error copying image {image_name} to cache. Reported: {e}') from e def _restore_image_unicast(self, repo, name, devpath, cache=False): @@ -245,7 +245,7 @@ class OgLiveOperations: shell=True, executable=OG_SHELL) (output, error) = ogRest.proc.communicate() - except Exception as e: + except OSError as e: raise OgError(f'Error when running "shell run" subprocess: {e}') from e if ogRest.proc.returncode != 0: |