]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
tools/ceph-dencoder: print human-readable error message
authorKefu Chai <kchai@redhat.com>
Mon, 5 Apr 2021 08:28:11 +0000 (16:28 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 5 Apr 2021 08:30:05 +0000 (16:30 +0800)
if $CEPH_LIB is not specified.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/tools/ceph-dencoder/ceph_dencoder.cc

index 2bb73db0854e272f4b250b2c1ad64eb857b0ff6a..ccf51575c738cf4f14266bb0f8fbc43a4c265db8 100644 (file)
@@ -23,6 +23,7 @@ namespace fs = std::filesystem;
 #include <experimental/filesystem>
 namespace fs = std::experimental::filesystem;
 #endif
+#include <iomanip>
 
 #include "ceph_ver.h"
 #include "include/types.h"
@@ -105,6 +106,12 @@ vector<DencoderPlugin> load_plugins()
   if (auto ceph_lib = getenv("CEPH_LIB"); ceph_lib) {
     mod_dir = ceph_lib;
   }
+  if (!fs::is_directory(mod_dir)) {
+    std::cerr << "unable to load dencoders from "
+             << std::quoted(mod_dir.native()) << ". "
+             << "it is not a directory." << std::endl;
+    return {};
+  }
   vector<DencoderPlugin> dencoder_plugins;
   for (auto& entry : fs::directory_iterator(mod_dir)) {
     static const string_view DENC_MOD_PREFIX = "denc-mod-";