Skip to content

Commit

Permalink
Improve error reporting format
Browse files Browse the repository at this point in the history
  • Loading branch information
kpushkaryov committed Dec 20, 2023
1 parent 9422040 commit e93fce6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pleskdistup/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,18 @@ def required_conditions_satisfied(upgrader: DistUpgrader, options: typing.Any, p
return False


def handle_error(error: str, logfile_path: PathType, util_name: str, status_flag_path: PathType) -> None:
def handle_error(
error: str,
logfile_path: PathType,
util_name: str,
status_flag_path: PathType,
upgrader: DistUpgrader,
) -> None:
print()
print(error)
print(messages.FAIL_MESSAGE_HEAD.format(logfile_path=logfile_path), end='')

error_message = f"{util_name} (version {pleskdistup.config.revision}) process has failed. Error: {error}.\n\n"
error_message = f"[{util_name}] (dist-upgrader {pleskdistup.config.revision}, upgrader module {upgrader.upgrader_name} {upgrader.upgrader_version}) process has failed. Error: {error}\n\n"
for line in files.get_last_lines(logfile_path, 100):
print(line, end='')
error_message += line
Expand Down Expand Up @@ -234,7 +240,7 @@ def do_convert(
print(messages.FINISH_RESTART_MESSAGE, end='')
systemd.do_reboot()
except Exception as e:
handle_error(str(e), logfile_path, util_name, options.status_flag_path)
handle_error(str(e), logfile_path, util_name, options.status_flag_path, upgrader)
return 1
else:
for stage_id, actions in actions_map.items():
Expand Down

0 comments on commit e93fce6

Please sign in to comment.