rfc: move folly::json::ParseError type to folly/json.h
authorRanjeeth Dasineni <ranjeeth@fb.com>
Fri, 1 Aug 2014 03:01:24 +0000 (20:01 -0700)
committerSara Golemon <sgolemon@fb.com>
Thu, 14 Aug 2014 18:49:04 +0000 (11:49 -0700)
Summary:
I don't know why this was in the cpp but seems pretty safe to move it to the .h
There are a few files that directly include json.cpp to get around this: https://fburl.com/30544625.
I need it for something else and if you dont see a problem I want to move it.

Test Plan: unittests

Reviewed By: pgriess@fb.com

Subscribers: simpkins, doug

FB internal diff: D1471958

Tasks: 3623725

folly/json.cpp
folly/json.h

index cd83b5adffb68209b8edb695a93ce14986f1aa92..ddd0afbec0f616feca79b08ecba7f1bd7b972f73 100644 (file)
@@ -256,26 +256,6 @@ private:
   serialization_opts const& opts_;
 };
 
-//////////////////////////////////////////////////////////////////////
-
-struct ParseError : std::runtime_error {
-  explicit ParseError(int line)
-    : std::runtime_error(to<std::string>("json parse error on line ", line))
-  {}
-
-  explicit ParseError(int line, std::string const& context,
-      std::string const& expected)
-    : std::runtime_error(to<std::string>("json parse error on line ", line,
-        !context.empty() ? to<std::string>(" near `", context, '\'')
-                        : "",
-        ": ", expected))
-  {}
-
-  explicit ParseError(std::string const& what)
-    : std::runtime_error("json parse error: " + what)
-  {}
-};
-
 // Wraps our input buffer with some helper functions.
 struct Input {
   explicit Input(StringPiece range, json::serialization_opts const* opts)
index 89d3b0682851a5b1d9f6ed6e907cd7dca6cc4c4f..5610e1cdd87573de2d387cbe82714c3fe400f020 100644 (file)
@@ -51,6 +51,27 @@ namespace folly {
 
 namespace json {
 
+  //////////////////////////////////////////////////////////////////////
+
+  struct ParseError : std::runtime_error {
+    explicit ParseError(int line)
+      : std::runtime_error(to<std::string>("json parse error on line ", line))
+    {}
+
+    explicit ParseError(int line, std::string const& context,
+        std::string const& expected)
+      : std::runtime_error(to<std::string>("json parse error on line ", line,
+          !context.empty() ? to<std::string>(" near `", context, '\'')
+                          : "",
+          ": ", expected))
+    {}
+
+    explicit ParseError(std::string const& msg)
+      : std::runtime_error("json parse error: " + msg)
+    {}
+  };
+
+
   struct serialization_opts {
     explicit serialization_opts()
       : allow_non_string_keys(false)