Commit c01cc7f1 authored by Nigel Tao's avatar Nigel Tao Committed by Commit Bot

Remove base::JSONReader::error_code method

Checking (result.error_code != JSON_NO_ERROR) is equivalent to checking
result.value (which has a base::Optional type, convertible to bool).
Callers don't care about error_code, other than == or != JSON_NO_ERROR.

Bug: 1069271
Bug: 1070409
Change-Id: I5483d116ee9d5813815118c495474ba50f4255e8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2154435Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Commit-Queue: Nigel Tao <nigeltao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#760243}
parent 4068336e
...@@ -147,10 +147,6 @@ std::unique_ptr<Value> JSONReader::ReadToValueDeprecated(StringPiece json) { ...@@ -147,10 +147,6 @@ std::unique_ptr<Value> JSONReader::ReadToValueDeprecated(StringPiece json) {
return value ? std::make_unique<Value>(std::move(*value)) : nullptr; return value ? std::make_unique<Value>(std::move(*value)) : nullptr;
} }
JSONReader::JsonParseError JSONReader::error_code() const {
return parser_->error_code();
}
std::string JSONReader::GetErrorMessage() const { std::string JSONReader::GetErrorMessage() const {
return parser_->GetErrorMessage(); return parser_->GetErrorMessage();
} }
......
...@@ -169,10 +169,6 @@ class BASE_EXPORT JSONReader { ...@@ -169,10 +169,6 @@ class BASE_EXPORT JSONReader {
// Non-static version of Read() above. // Non-static version of Read() above.
std::unique_ptr<Value> ReadToValueDeprecated(StringPiece json); std::unique_ptr<Value> ReadToValueDeprecated(StringPiece json);
// Returns the error code if the last call to ReadToValue() failed.
// Returns JSON_NO_ERROR otherwise.
JsonParseError error_code() const;
// Converts error_code_ to a human-readable string, including line and column // Converts error_code_ to a human-readable string, including line and column
// numbers if appropriate. // numbers if appropriate.
std::string GetErrorMessage() const; std::string GetErrorMessage() const;
......
...@@ -739,7 +739,6 @@ TEST(JSONReaderTest, InvalidSanity) { ...@@ -739,7 +739,6 @@ TEST(JSONReaderTest, InvalidSanity) {
JSONReader reader; JSONReader reader;
LOG(INFO) << "Sanity test " << i << ": <" << kInvalidJson[i] << ">"; LOG(INFO) << "Sanity test " << i << ": <" << kInvalidJson[i] << ">";
EXPECT_FALSE(reader.ReadToValue(kInvalidJson[i])); EXPECT_FALSE(reader.ReadToValue(kInvalidJson[i]));
EXPECT_NE(JSONReader::JSON_NO_ERROR, reader.error_code());
EXPECT_NE("", reader.GetErrorMessage()); EXPECT_NE("", reader.GetErrorMessage());
} }
} }
...@@ -749,7 +748,7 @@ TEST(JSONReaderTest, IllegalTrailingNull) { ...@@ -749,7 +748,7 @@ TEST(JSONReaderTest, IllegalTrailingNull) {
std::string json_string(json, sizeof(json)); std::string json_string(json, sizeof(json));
JSONReader reader; JSONReader reader;
EXPECT_FALSE(reader.ReadToValue(json_string)); EXPECT_FALSE(reader.ReadToValue(json_string));
EXPECT_EQ(JSONReader::JSON_UNEXPECTED_DATA_AFTER_ROOT, reader.error_code()); EXPECT_NE("", reader.GetErrorMessage());
} }
TEST(JSONReaderTest, ASCIIControlCodes) { TEST(JSONReaderTest, ASCIIControlCodes) {
......
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