From 8e5b7acad15a1aacb8cc35b782642cc34d891657 Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Wed, 17 Sep 2014 15:43:17 +0200 Subject: [PATCH] tools: display boost::program_options errors Instead of silently discarding them. Do not display the usage on error as it will probably hide the error message that shows before it. Signed-off-by: Loic Dachary --- src/tools/ceph_monstore_tool.cc | 4 ++-- src/tools/ceph_objectstore_tool.cc | 6 +++--- src/tools/ceph_osdomap_tool.cc | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/tools/ceph_monstore_tool.cc b/src/tools/ceph_monstore_tool.cc index c5cb0e1152e56..547f86d96ac9a 100644 --- a/src/tools/ceph_monstore_tool.cc +++ b/src/tools/ceph_monstore_tool.cc @@ -141,8 +141,8 @@ int main(int argc, char **argv) { parsed, vm); po::notify(vm); - } catch (...) { - cout << desc << std::endl; + } catch(po::error &e) { + std::cerr << e.what() << std::endl; return 1; } diff --git a/src/tools/ceph_objectstore_tool.cc b/src/tools/ceph_objectstore_tool.cc index 827874f704624..3d09f6e81f397 100644 --- a/src/tools/ceph_objectstore_tool.cc +++ b/src/tools/ceph_objectstore_tool.cc @@ -1843,9 +1843,9 @@ int main(int argc, char **argv) po::command_line_parser(argc, argv).options(all).allow_unregistered().positional(pd).run(); po::store( parsed, vm); po::notify(vm); - } - catch(...) { - usage(desc); + } catch(po::error &e) { + std::cerr << e.what() << std::endl; + return 1; } if (vm.count("help")) { diff --git a/src/tools/ceph_osdomap_tool.cc b/src/tools/ceph_osdomap_tool.cc index 3e4cae28396b8..191cb08983ee9 100644 --- a/src/tools/ceph_osdomap_tool.cc +++ b/src/tools/ceph_osdomap_tool.cc @@ -49,8 +49,8 @@ int main(int argc, char **argv) { parsed, vm); po::notify(vm); - } catch (...) { - cout << desc << std::endl; + } catch(po::error &e) { + std::cerr << e.what() << std::endl; return 1; } -- 2.39.5