Commit aa6cde1f authored by Petr Lapukhov's avatar Petr Lapukhov Committed by Facebook Github Bot

(cosmetic) Unify error name style with json_patch

Summary: As titled, purely for uniformity.

Reviewed By: yfeldblum

Differential Revision: D10098066

fbshipit-source-id: 12d78fcc60805284d3d85f405475e63a85799041
parent c4c3ce43
...@@ -29,7 +29,7 @@ Expected<json_pointer, json_pointer::parse_error> json_pointer::try_parse( ...@@ -29,7 +29,7 @@ Expected<json_pointer, json_pointer::parse_error> json_pointer::try_parse(
} }
if (str.at(0) != '/') { if (str.at(0) != '/') {
return makeUnexpected(parse_error::INVALID_FIRST_CHARACTER); return makeUnexpected(parse_error::invalid_first_character);
} }
std::vector<std::string> tokens; std::vector<std::string> tokens;
...@@ -38,7 +38,7 @@ Expected<json_pointer, json_pointer::parse_error> json_pointer::try_parse( ...@@ -38,7 +38,7 @@ Expected<json_pointer, json_pointer::parse_error> json_pointer::try_parse(
for (auto& token : tokens) { for (auto& token : tokens) {
if (!unescape(token)) { if (!unescape(token)) {
return makeUnexpected(parse_error::INVALID_ESCAPE_SEQUENCE); return makeUnexpected(parse_error::invalid_escape_sequence);
} }
} }
...@@ -52,10 +52,10 @@ json_pointer json_pointer::parse(StringPiece const str) { ...@@ -52,10 +52,10 @@ json_pointer json_pointer::parse(StringPiece const str) {
return std::move(res.value()); return std::move(res.value());
} }
switch (res.error()) { switch (res.error()) {
case parse_error::INVALID_FIRST_CHARACTER: case parse_error::invalid_first_character:
throw json_pointer::parse_exception( throw json_pointer::parse_exception(
"non-empty JSON pointer string does not start with '/'"); "non-empty JSON pointer string does not start with '/'");
case parse_error::INVALID_ESCAPE_SEQUENCE: case parse_error::invalid_escape_sequence:
throw json_pointer::parse_exception( throw json_pointer::parse_exception(
"Invalid escape sequence in JSON pointer string"); "Invalid escape sequence in JSON pointer string");
default: default:
......
...@@ -35,8 +35,8 @@ namespace folly { ...@@ -35,8 +35,8 @@ namespace folly {
class json_pointer { class json_pointer {
public: public:
enum class parse_error { enum class parse_error {
INVALID_FIRST_CHARACTER, invalid_first_character,
INVALID_ESCAPE_SEQUENCE, invalid_escape_sequence,
}; };
class parse_exception : public std::runtime_error { class parse_exception : public std::runtime_error {
......
...@@ -38,13 +38,13 @@ TEST_F(JsonPointerTest, ValidPointers) { ...@@ -38,13 +38,13 @@ TEST_F(JsonPointerTest, ValidPointers) {
TEST_F(JsonPointerTest, InvalidPointers) { TEST_F(JsonPointerTest, InvalidPointers) {
EXPECT_EQ( EXPECT_EQ(
json_pointer::parse_error::INVALID_FIRST_CHARACTER, json_pointer::parse_error::invalid_first_character,
json_pointer::try_parse("a").error()); json_pointer::try_parse("a").error());
EXPECT_EQ( EXPECT_EQ(
json_pointer::parse_error::INVALID_ESCAPE_SEQUENCE, json_pointer::parse_error::invalid_escape_sequence,
json_pointer::try_parse("/~").error()); json_pointer::try_parse("/~").error());
EXPECT_EQ( EXPECT_EQ(
json_pointer::parse_error::INVALID_ESCAPE_SEQUENCE, json_pointer::parse_error::invalid_escape_sequence,
json_pointer::try_parse("/~x").error()); json_pointer::try_parse("/~x").error());
} }
......
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