From: David Zafman Date: Fri, 5 Dec 2014 02:27:50 +0000 (-0800) Subject: ceph_objectstore_tool: Improve object spec parsing error messages X-Git-Tag: v0.92~32^2~7^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=de6384fda183801c16af1b61ed36eaed289bb4f6;p=ceph.git ceph_objectstore_tool: Improve object spec parsing error messages Signed-off-by: David Zafman --- diff --git a/src/tools/ceph_objectstore_tool.cc b/src/tools/ceph_objectstore_tool.cc index 114b2fc3ec1c..d4821b5ff058 100644 --- a/src/tools/ceph_objectstore_tool.cc +++ b/src/tools/ceph_objectstore_tool.cc @@ -2350,6 +2350,12 @@ int main(int argc, char **argv) } json_spirit::Array array = v.get_array(); vector::iterator i = array.begin(); + if (i->type() != json_spirit::str_type) { + ss << "object '" << object + << "' must be a JSON array with the first element a string but " + << "found type " << v.type() << " instead"; + throw std::runtime_error(ss.str()); + } string object_pgidstr = i->get_str(); spg_t object_pgid; object_pgid.parse(object_pgidstr.c_str()); @@ -2365,7 +2371,12 @@ int main(int argc, char **argv) pgid = object_pgid; } i++; - ghobj.decode(*i); + try { + ghobj.decode(*i); + } catch (std::runtime_error& e) { + ss << "Decode object json error: " << e.what(); + throw std::runtime_error(ss.str()); + } } } catch (std::runtime_error& e) { cerr << e.what() << std::endl;