]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_objectstore_tool: Improve object spec parsing error messages
authorDavid Zafman <dzafman@redhat.com>
Fri, 5 Dec 2014 02:27:50 +0000 (18:27 -0800)
committerDavid Zafman <dzafman@redhat.com>
Tue, 3 Mar 2015 19:20:58 +0000 (11:20 -0800)
Signed-off-by: David Zafman <dzafman@redhat.com>
(cherry picked from commit de6384fda183801c16af1b61ed36eaed289bb4f6)

src/tools/ceph_objectstore_tool.cc

index 1bb7ba2c33877d90000f8b38e2650abb1d9a4dbc..ff2eeb18e05b585bbb044d66d5149e2d06ec0874 100644 (file)
@@ -2344,6 +2344,12 @@ int main(int argc, char **argv)
        }
        json_spirit::Array array = v.get_array();
        vector<json_spirit::Value>::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;