Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: base/json/json_reader.cc

Issue 1571633002: Pass Manifest JSON paser error line and column number to console. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add comments Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/json/json_reader.h ('k') | content/renderer/manifest/manifest_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/json/json_reader.h" 5 #include "base/json/json_reader.h"
6 6
7 #include "base/json/json_parser.h" 7 #include "base/json/json_parser.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 10
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 scoped_ptr<Value> JSONReader::Read(const StringPiece& json, int options) { 52 scoped_ptr<Value> JSONReader::Read(const StringPiece& json, int options) {
53 internal::JSONParser parser(options); 53 internal::JSONParser parser(options);
54 return make_scoped_ptr(parser.Parse(json)); 54 return make_scoped_ptr(parser.Parse(json));
55 } 55 }
56 56
57 57
58 // static 58 // static
59 scoped_ptr<Value> JSONReader::ReadAndReturnError(const StringPiece& json, 59 scoped_ptr<Value> JSONReader::ReadAndReturnError(const StringPiece& json,
60 int options, 60 int options,
61 int* error_code_out, 61 int* error_code_out,
62 std::string* error_msg_out) { 62 std::string* error_msg_out,
63 int* error_line_out,
64 int* error_column_out) {
63 internal::JSONParser parser(options); 65 internal::JSONParser parser(options);
64 scoped_ptr<Value> root(parser.Parse(json)); 66 scoped_ptr<Value> root(parser.Parse(json));
65 if (!root) { 67 if (!root) {
66 if (error_code_out) 68 if (error_code_out)
67 *error_code_out = parser.error_code(); 69 *error_code_out = parser.error_code();
68 if (error_msg_out) 70 if (error_msg_out)
69 *error_msg_out = parser.GetErrorMessage(); 71 *error_msg_out = parser.GetErrorMessage();
72 if (error_line_out)
73 *error_line_out = parser.error_line();
74 if (error_column_out)
75 *error_column_out = parser.error_column();
70 } 76 }
71 77
72 return root; 78 return root;
73 } 79 }
74 80
75 // static 81 // static
76 std::string JSONReader::ErrorCodeToString(JsonParseError error_code) { 82 std::string JSONReader::ErrorCodeToString(JsonParseError error_code) {
77 switch (error_code) { 83 switch (error_code) {
78 case JSON_NO_ERROR: 84 case JSON_NO_ERROR:
79 return std::string(); 85 return std::string();
(...skipping 25 matching lines...) Expand all
105 111
106 JSONReader::JsonParseError JSONReader::error_code() const { 112 JSONReader::JsonParseError JSONReader::error_code() const {
107 return parser_->error_code(); 113 return parser_->error_code();
108 } 114 }
109 115
110 std::string JSONReader::GetErrorMessage() const { 116 std::string JSONReader::GetErrorMessage() const {
111 return parser_->GetErrorMessage(); 117 return parser_->GetErrorMessage();
112 } 118 }
113 119
114 } // namespace base 120 } // namespace base
OLDNEW
« no previous file with comments | « base/json/json_reader.h ('k') | content/renderer/manifest/manifest_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698