Fix: lttng-destroy: string formating error when default session is unset
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 21 Mar 2024 19:31:25 +0000 (15:31 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 22 Mar 2024 14:56:00 +0000 (10:56 -0400)
commit0729ea5558053d5a1a0d7aea51febf63ee1f3b3f
tree1c18ec7b94a72b4ed5a68fb8036833a71d0863a6
parent9cde3a4ab8b763df804f8105728d90f59521438b
Fix: lttng-destroy: string formating error when default session is unset

Using `lttng destroy` when no default session is set in .lttngrc results
in the following print-out:

  Error: Can't find valid lttng config /root/lttng-build/home/.lttngrc
  Did you create a session? (lttng create <my_session>)
  Error: Failed to format string: string pointer is null

This is because the client attempts to format the following message:
  ERR_FMT("Session `{}` not found", spec.value);

When no default session could be found in .lttngrc, spec.value is left
at nullptr and it is assumed that the listing succeeded.

A new CLI-specific exception, no_default_session_error, is added to the
project and thrown when the session listing fails. This allows the
calling code to mark the listing as having failed.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I33b4f38a424f22dfa9d3628cf12441b59df53f12
src/bin/lttng/Makefile.am
src/bin/lttng/commands/destroy.cpp
src/bin/lttng/commands/start.cpp
src/bin/lttng/commands/stop.cpp
src/bin/lttng/utils.cpp
src/common/exception.hpp
This page took 0.031337 seconds and 4 git commands to generate.