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.80.10~69^2~23 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=60e9a8120b292628ee4e5ef33fe933222609b861;p=ceph.git ceph_objectstore_tool: Improve object spec parsing error messages Signed-off-by: David Zafman (cherry picked from commit de6384fda183801c16af1b61ed36eaed289bb4f6) --- diff --git a/src/tools/ceph_objectstore_tool.cc b/src/tools/ceph_objectstore_tool.cc index 1bb7ba2c338..ff2eeb18e05 100644 --- a/src/tools/ceph_objectstore_tool.cc +++ b/src/tools/ceph_objectstore_tool.cc @@ -2344,6 +2344,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()); @@ -2359,7 +2365,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;