Commit 9633f475 authored by Ranjeeth Dasineni's avatar Ranjeeth Dasineni Committed by Sara Golemon

rfc: move folly::json::ParseError type to folly/json.h

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
parent 9f160366
......@@ -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)
......
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment