Skip to content

Commit

Permalink
unexpected error message is now formatted and takes in an error message
Browse files Browse the repository at this point in the history
  • Loading branch information
a-dubs committed Nov 27, 2023
1 parent 17aa472 commit 64a822f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion uaclient/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1764,7 +1764,7 @@ def wrapper(*args, **kwargs):
LOG.exception("Unhandled exception, please file a bug")
lock.clear_lock_file_if_present()
event.info(
info_msg=messages.UNEXPECTED_ERROR.msg, file_type=sys.stderr
info_msg=messages.UNEXPECTED_ERROR.format(error_msg=str(e)), file_type=sys.stderr
)
event.error(
error_msg=getattr(e, "msg", str(e)), error_type="exception"
Expand Down
2 changes: 1 addition & 1 deletion uaclient/cli/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ class TestMain:
(
(
TypeError("'NoneType' object is not subscriptable"),
messages.UNEXPECTED_ERROR.msg,
messages.UNEXPECTED_ERROR.format(error_msg="'NoneType' object is not subscriptable").msg,
"Unhandled exception, please file a bug",
),
),
Expand Down
2 changes: 1 addition & 1 deletion uaclient/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ def process_entitlements_delta(
if unexpected_error:
raise exceptions.AttachFailureUnknownError(
failed_services=[
(name, messages.UNEXPECTED_ERROR) for name in failed_services
(name, messages.UNEXPECTED_ERROR.format(error_msg=str(e))) for name in failed_services
]
)
elif delta_error:
Expand Down
9 changes: 5 additions & 4 deletions uaclient/messages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1531,13 +1531,14 @@ def __repr__(self):
the --access-only flag.""",
)

UNEXPECTED_ERROR = NamedMessage(
UNEXPECTED_ERROR = FormattedNamedMessage(
"unexpected-error",
t.gettext(
"""\
Unexpected error(s) occurred.
For more details, see the log: /var/log/ubuntu-advantage.log
To file a bug run: ubuntu-bug ubuntu-advantage-tools"""
Unexpected error(s) occurred: {error_msg}
For more details, see the log: ~/.cache/ubuntu-pro/ubuntu-pro.log
First, try searching online for solutions to this error.
Otherwise, file a bug using the command: ubuntu-bug ubuntu-advantage-tools"""
),
)

Expand Down

0 comments on commit 64a822f

Please sign in to comment.