Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cephfs-shell: make onecmd() print proper error msg #46110

Merged
merged 1 commit into from May 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/tools/cephfs/cephfs-shell
Expand Up @@ -18,6 +18,7 @@ import errno

from cmd2 import Cmd
from cmd2 import __version__ as cmd2_version
from cmd2.exceptions import Cmd2ArgparseError
from distutils.version import LooseVersion

if sys.version_info.major < 3:
Expand Down Expand Up @@ -466,7 +467,13 @@ class CephFSShell(Cmd):
except (libcephfs.Error, Exception) as e:
if shell.debug:
traceback.print_exc(file=sys.stdout)
set_exit_code_msg(msg=e)
if isinstance(e, Cmd2ArgparseError):
# NOTE: In case of Cmd2ArgparseError the error message is
# already printed beforehand (plus Cmd2ArgparseError
# instances have empty message)
pass
else:
set_exit_code_msg(msg=f'{type(e).__name__}: {e}')

class path_to_bytes(argparse.Action):
def __call__(self, parser, namespace, values, option_string=None):
Expand Down