]> 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)
committerLoic Dachary <ldachary@redhat.com>
Fri, 5 Dec 2014 20:09:42 +0000 (21:09 +0100)
Signed-off-by: David Zafman <dzafman@redhat.com>
src/tools/ceph_objectstore_tool.cc

index 114b2fc3ec1c0db525d52042f709c41edab7fff5..d4821b5ff0589bd04c4d36c748c35820a22d0b9f 100644 (file)
@@ -2350,6 +2350,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());
@@ -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;