X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Fdestroy.cpp;h=ef4b914d38bd39f124debce1dfb31600ba572a50;hb=HEAD;hp=019906a208d1af7bc0673413f045d783bf3a2ae4;hpb=6e11909ebb204e4a0f9651dc6c58f74c8376a094;p=lttng-tools.git diff --git a/src/bin/lttng/commands/destroy.cpp b/src/bin/lttng/commands/destroy.cpp index 019906a20..ef4b914d3 100644 --- a/src/bin/lttng/commands/destroy.cpp +++ b/src/bin/lttng/commands/destroy.cpp @@ -7,6 +7,7 @@ #define _LGPL_SOURCE #include "../command.hpp" +#include "../exception.hpp" #include #include @@ -74,7 +75,7 @@ cmd_error_code destroy_session(const lttng_session& session) ret = lttng_stop_tracing_no_wait(session.name); if (ret < 0 && ret != -LTTNG_ERR_TRACE_ALREADY_STOPPED) { - LTTNG_THROW_CTL(fmt::format("Failed to stop session `{}`", session.name), + LTTNG_THROW_CTL(lttng::format("Failed to stop session `{}`", session.name), static_cast(-ret)); } @@ -110,7 +111,8 @@ cmd_error_code destroy_session(const lttng_session& session) } while (ret != 0); } - std::unique_ptr::deleter> + std::unique_ptr::deleter> stats_str; if (!session_was_already_stopped) { char *raw_stats_str = nullptr; @@ -134,7 +136,8 @@ cmd_error_code destroy_session(const lttng_session& session) auto ctl_ret_code = lttng_destroy_session_ext(session.name, &raw_destruction_handle); if (ctl_ret_code != LTTNG_OK) { - LTTNG_THROW_CTL(fmt::format("Failed to destroy session `{}`", session.name), + LTTNG_THROW_CTL(lttng::format("Failed to destroy session `{}`", + session.name), ctl_ret_code); } @@ -184,7 +187,8 @@ cmd_error_code destroy_session(const lttng_session& session) } if (ctl_ret_code != LTTNG_OK) { - LTTNG_THROW_CTL(fmt::format("Failed to destroy session `{}`", session.name), + LTTNG_THROW_CTL(lttng::format("Failed to destroy session `{}`", + session.name), ctl_ret_code); } @@ -240,7 +244,7 @@ cmd_error_code destroy_session(const lttng_session& session) * destroy the file. */ const auto session_name = - lttng::make_unique_wrapper(get_session_name_quiet()); + lttng::make_unique_wrapper(get_session_name_quiet()); if (session_name && !strncmp(session.name, session_name.get(), NAME_MAX)) { config_destroy_default(); } @@ -269,6 +273,14 @@ cmd_error_code destroy_sessions(const lttng::cli::session_spec& spec) lttng_strerror(-ctl_exception.code())); listing_failed = true; return {}; + } catch (const lttng::cli::no_default_session_error& cli_exception) { + /* + * The retrieval of the default session name already logs + * an error when it fails. There is no value in printing + * anything about this exception. + */ + listing_failed = true; + return {}; } }();