diff options
author | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-03-18 14:17:12 +0100 |
---|---|---|
committer | lupoDharkael <izhe@hotmail.es> | 2024-03-21 10:29:57 +0100 |
commit | 2a4ce65a20b41a670b274cb473d46e62b4f3c913 (patch) | |
tree | 947c45ef966b226cbb980beabdc964184aa81a02 /src/utils/uefi.py | |
parent | 0cbf16461e05bc5f15d3436763667b1d34869826 (diff) |
src: centralize error logging into send_internal_server_error
Use only the exception messages as the main resource for error
messages.
The previous error code had string duplication in the form of:
logging.error('msg here')
raise Exception('msg here')
That approach also has the downside of having log duplication as
it had the local logging.err() and a global logging.exception()
inside send_internal_server_error capturing the exception message.
The actual code only requires raising an exception with a proper
error message.
Improve exception messages to give more error context.
Log every AssertionError as a backtrace.
Use the 'raise Exception from e' syntax to modify the a previously
raised exception 'e' into an exception with aditional context or
different type. This also prevents the message that warns about
newer exceptions being launch after an initial exception.
Diffstat (limited to 'src/utils/uefi.py')
-rw-r--r-- | src/utils/uefi.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/utils/uefi.py b/src/utils/uefi.py index 67f1354..e113512 100644 --- a/src/utils/uefi.py +++ b/src/utils/uefi.py @@ -104,6 +104,5 @@ def efibootmgr_create_bootentry(disk, part, loader, label, add_to_bootorder=True logging.info(f'{EFIBOOTMGR_BIN} command creating boot entry: {efibootmgr_cmd}') try: proc = subprocess.run(shlex.split(efibootmgr_cmd), check=True, text=True) - except subprocess.CalledProcessError as e: - logging.error(f'Unexpected error adding boot entry to nvram. UEFI firmware might be buggy?.') - raise e + except OSError as e: + raise OSError(f'Unexpected error adding boot entry to nvram. UEFI firmware might be buggy') from e |