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

Side by Side Diff: components/policy/core/common/schema_map.cc

Issue 139853013: Improve error message display for Schema::Validate() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@expand-policy-schema-3
Patch Set: fix comments Created 6 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/policy/core/common/schema_map.h" 5 #include "components/policy/core/common/schema_map.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "components/policy/core/common/policy_bundle.h" 9 #include "components/policy/core/common/policy_bundle.h"
10 #include "components/policy/core/common/policy_map.h" 10 #include "components/policy/core/common/policy_map.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 if (!schema->valid()) 57 if (!schema->valid())
58 continue; 58 continue;
59 59
60 PolicyMap* map = it->second; 60 PolicyMap* map = it->second;
61 for (PolicyMap::const_iterator it_map = map->begin(); 61 for (PolicyMap::const_iterator it_map = map->begin();
62 it_map != map->end();) { 62 it_map != map->end();) {
63 const std::string& policy_name = it_map->first; 63 const std::string& policy_name = it_map->first;
64 const base::Value* policy_value = it_map->second.value; 64 const base::Value* policy_value = it_map->second.value;
65 Schema policy_schema = schema->GetProperty(policy_name); 65 Schema policy_schema = schema->GetProperty(policy_name);
66 ++it_map; 66 ++it_map;
67 std::string error_path;
67 std::string error; 68 std::string error;
68 if (!policy_value || 69 if (!policy_value ||
69 !policy_schema.Validate(*policy_value, SCHEMA_STRICT, &error)) { 70 !policy_schema.Validate(*policy_value,
71 SCHEMA_STRICT,
72 &error_path,
73 &error)) {
70 LOG(ERROR) << "Dropping policy " << policy_name << " for " 74 LOG(ERROR) << "Dropping policy " << policy_name << " for "
71 << it->first.component_id 75 << it->first.component_id
72 << " because it's not valid: " << error; 76 << " because it's not valid: " << error
77 << " at " << error_path;
73 map->Erase(policy_name); 78 map->Erase(policy_name);
74 } 79 }
75 } 80 }
76 } 81 }
77 } 82 }
78 83
79 bool SchemaMap::HasComponents() const { 84 bool SchemaMap::HasComponents() const {
80 for (DomainMap::const_iterator domain = map_.begin(); 85 for (DomainMap::const_iterator domain = map_.begin();
81 domain != map_.end(); ++domain) { 86 domain != map_.end(); ++domain) {
82 if (domain->first == POLICY_DOMAIN_CHROME) 87 if (domain->first == POLICY_DOMAIN_CHROME)
(...skipping 20 matching lines...) Expand all
103 for (ComponentMap::const_iterator comp = components.begin(); 108 for (ComponentMap::const_iterator comp = components.begin();
104 comp != components.end(); ++comp) { 109 comp != components.end(); ++comp) {
105 PolicyNamespace ns(domain->first, comp->first); 110 PolicyNamespace ns(domain->first, comp->first);
106 if (!other->GetSchema(ns)) 111 if (!other->GetSchema(ns))
107 list->push_back(ns); 112 list->push_back(ns);
108 } 113 }
109 } 114 }
110 } 115 }
111 116
112 } // namespace policy 117 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698