Remove domain from weave::Error

We don't filter out errors by domain in libweave.

BUG:26071451
Change-Id: I2114450aca1c8ede71cc45f19bd8e71d3464cb73
Reviewed-on: https://weave-review.googlesource.com/2289
Reviewed-by: Alex Vakulenko <avakulenko@google.com>
diff --git a/src/component_manager_impl.cc b/src/component_manager_impl.cc
index 3f6ebf9..a4f5740 100644
--- a/src/component_manager_impl.cc
+++ b/src/component_manager_impl.cc
@@ -47,8 +47,7 @@
       return false;
   }
   if (root->GetWithoutPathExpansion(name, nullptr)) {
-    Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
-                       errors::commands::kInvalidState,
+    Error::AddToPrintf(error, FROM_HERE, errors::commands::kInvalidState,
                        "Component '%s' already exists at path '%s'",
                        name.c_str(), path.c_str());
     return false;
@@ -57,8 +56,7 @@
   // Check to make sure the declared traits are already defined.
   for (const std::string& trait : traits) {
     if (!FindTraitDefinition(trait)) {
-      Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
-                         errors::commands::kInvalidPropValue,
+      Error::AddToPrintf(error, FROM_HERE, errors::commands::kInvalidPropValue,
                          "Trait '%s' is undefined", trait.c_str());
       return false;
     }
@@ -110,8 +108,7 @@
   }
 
   if (!root->RemoveWithoutPathExpansion(name, nullptr)) {
-    Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
-                       errors::commands::kInvalidState,
+    Error::AddToPrintf(error, FROM_HERE, errors::commands::kInvalidState,
                        "Component '%s' does not exist at path '%s'",
                        name.c_str(), path.c_str());
     return false;
@@ -135,8 +132,7 @@
 
   base::ListValue* array_value = nullptr;
   if (!root->GetListWithoutPathExpansion(name, &array_value)) {
-    Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
-                       errors::commands::kInvalidState,
+    Error::AddToPrintf(error, FROM_HERE, errors::commands::kInvalidState,
                        "There is no component array named '%s' at path '%s'",
                        name.c_str(), path.c_str());
     return false;
@@ -144,8 +140,7 @@
 
   if (!array_value->Remove(index, nullptr)) {
     Error::AddToPrintf(
-        error, FROM_HERE, errors::commands::kDomain,
-        errors::commands::kInvalidState,
+        error, FROM_HERE, errors::commands::kInvalidState,
         "Component array '%s' at path '%s' does not have an element %zu",
         name.c_str(), path.c_str(), index);
     return false;
@@ -170,8 +165,7 @@
   // definition is exactly the same, or else this is an error.
   for (base::DictionaryValue::Iterator it(dict); !it.IsAtEnd(); it.Advance()) {
     if (it.value().GetType() != base::Value::TYPE_DICTIONARY) {
-      Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
-                         errors::commands::kTypeMismatch,
+      Error::AddToPrintf(error, FROM_HERE, errors::commands::kTypeMismatch,
                          "Trait '%s' must be an object", it.key().c_str());
       result = false;
       break;
@@ -179,8 +173,7 @@
     const base::DictionaryValue* existing_def = nullptr;
     if (traits_.GetDictionary(it.key(), &existing_def)) {
       if (!existing_def->Equals(&it.value())) {
-        Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
-                           errors::commands::kTypeMismatch,
+        Error::AddToPrintf(error, FROM_HERE, errors::commands::kTypeMismatch,
                            "Trait '%s' cannot be redefined", it.key().c_str());
         result = false;
         break;
@@ -240,10 +233,10 @@
     return nullptr;
 
   if (role < minimal_role) {
-    Error::AddToPrintf(
-        error, FROM_HERE, errors::commands::kDomain, "access_denied",
-        "User role '%s' less than minimal: '%s'", EnumToString(role).c_str(),
-        EnumToString(minimal_role).c_str());
+    Error::AddToPrintf(error, FROM_HERE, "access_denied",
+                       "User role '%s' less than minimal: '%s'",
+                       EnumToString(role).c_str(),
+                       EnumToString(minimal_role).c_str());
     return nullptr;
   }
 
@@ -256,7 +249,7 @@
     component_path = FindComponentWithTrait(trait_name);
     if (component_path.empty()) {
       Error::AddToPrintf(
-          error, FROM_HERE, errors::commands::kDomain, "unrouted_command",
+          error, FROM_HERE, "unrouted_command",
           "Unable route command '%s' because there is no component supporting"
           "trait '%s'",
           command_instance->GetName().c_str(), trait_name.c_str());
@@ -286,8 +279,7 @@
   }
 
   if (!trait_supported) {
-    Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
-                       "trait_not_supported",
+    Error::AddToPrintf(error, FROM_HERE, "trait_not_supported",
                        "Component '%s' doesn't support trait '%s'",
                        component_path.c_str(), pair.first.c_str());
     return nullptr;
@@ -361,8 +353,7 @@
                                           ErrorPtr* error) const {
   const base::DictionaryValue* command = FindCommandDefinition(command_name);
   if (!command) {
-    Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
-                       errors::commands::kInvalidCommandName,
+    Error::AddToPrintf(error, FROM_HERE, errors::commands::kInvalidCommandName,
                        "Command definition for '%s' not found",
                        command_name.c_str());
     return false;
@@ -423,14 +414,12 @@
     return nullptr;
   auto pair = SplitAtFirst(name, ".", true);
   if (pair.first.empty()) {
-    Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
-                       errors::commands::kPropertyMissing,
+    Error::AddToPrintf(error, FROM_HERE, errors::commands::kPropertyMissing,
                        "Empty state package in '%s'", name.c_str());
     return nullptr;
   }
   if (pair.second.empty()) {
-    Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
-                       errors::commands::kPropertyMissing,
+    Error::AddToPrintf(error, FROM_HERE, errors::commands::kPropertyMissing,
                        "State property name not specified in '%s'",
                        name.c_str());
     return nullptr;
@@ -438,8 +427,7 @@
   std::string key = base::StringPrintf("state.%s", name.c_str());
   const base::Value* value = nullptr;
   if (!component->Get(key, &value)) {
-    Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
-                       errors::commands::kPropertyMissing,
+    Error::AddToPrintf(error, FROM_HERE, errors::commands::kPropertyMissing,
                        "State property '%s' not found in component '%s'",
                        name.c_str(), component_path.c_str());
   }
@@ -453,14 +441,12 @@
   base::DictionaryValue dict;
   auto pair = SplitAtFirst(name, ".", true);
   if (pair.first.empty()) {
-    Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
-                       errors::commands::kPropertyMissing,
+    Error::AddToPrintf(error, FROM_HERE, errors::commands::kPropertyMissing,
                        "Empty state package in '%s'", name.c_str());
     return false;
   }
   if (pair.second.empty()) {
-    Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
-                       errors::commands::kPropertyMissing,
+    Error::AddToPrintf(error, FROM_HERE, errors::commands::kPropertyMissing,
                        "State property name not specified in '%s'",
                        name.c_str());
     return false;
@@ -532,8 +518,7 @@
   for (base::DictionaryValue::Iterator it(dict); !it.IsAtEnd(); it.Advance()) {
     const base::DictionaryValue* command_dict = nullptr;
     if (!it.value().GetAsDictionary(&command_dict)) {
-      Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
-                         errors::commands::kTypeMismatch,
+      Error::AddToPrintf(error, FROM_HERE, errors::commands::kTypeMismatch,
                          "Package '%s' must be an object", it.key().c_str());
       result = false;
       continue;
@@ -544,7 +529,7 @@
       std::string key = base::StringPrintf("%s.commands.%s", it.key().c_str(),
                                            it_def.key().c_str());
       if (traits_.GetDictionary(key, nullptr)) {
-        Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
+        Error::AddToPrintf(error, FROM_HERE,
                            errors::commands::kInvalidPropValue,
                            "Redefining command '%s.%s'", it.key().c_str(),
                            it_def.key().c_str());
@@ -571,8 +556,7 @@
   for (base::DictionaryValue::Iterator it(dict); !it.IsAtEnd(); it.Advance()) {
     const base::DictionaryValue* state_dict = nullptr;
     if (!it.value().GetAsDictionary(&state_dict)) {
-      Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
-                         errors::commands::kTypeMismatch,
+      Error::AddToPrintf(error, FROM_HERE, errors::commands::kTypeMismatch,
                          "Package '%s' must be an object", it.key().c_str());
       result = false;
       continue;
@@ -583,7 +567,7 @@
       std::string key = base::StringPrintf("%s.state.%s", it.key().c_str(),
                                            it_def.key().c_str());
       if (traits_.GetDictionary(key, nullptr)) {
-        Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
+        Error::AddToPrintf(error, FROM_HERE,
                            errors::commands::kInvalidPropValue,
                            "Redefining state property '%s.%s'",
                            it.key().c_str(), it_def.key().c_str());
@@ -689,15 +673,13 @@
     auto element = SplitAtFirst(parts[i], "[", true);
     int array_index = -1;
     if (element.first.empty()) {
-      Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
-                         errors::commands::kPropertyMissing,
+      Error::AddToPrintf(error, FROM_HERE, errors::commands::kPropertyMissing,
                          "Empty path element at '%s'", root_path.c_str());
       return nullptr;
     }
     if (!element.second.empty()) {
       if (element.second.back() != ']') {
-        Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
-                           errors::commands::kPropertyMissing,
+        Error::AddToPrintf(error, FROM_HERE, errors::commands::kPropertyMissing,
                            "Invalid array element syntax '%s'",
                            parts[i].c_str());
         return nullptr;
@@ -707,7 +689,7 @@
       base::TrimWhitespaceASCII(element.second, base::TrimPositions::TRIM_ALL,
                                 &index_str);
       if (!base::StringToInt(index_str, &array_index) || array_index < 0) {
-        Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
+        Error::AddToPrintf(error, FROM_HERE,
                            errors::commands::kInvalidPropValue,
                            "Invalid array index '%s'", element.second.c_str());
         return nullptr;
@@ -719,8 +701,7 @@
       // points to the actual parent component. We need the root to point to
       // the 'components' element containing child sub-components instead.
       if (!root->GetDictionary("components", &root)) {
-        Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
-                           errors::commands::kPropertyMissing,
+        Error::AddToPrintf(error, FROM_HERE, errors::commands::kPropertyMissing,
                            "Component '%s' does not exist at '%s'",
                            element.first.c_str(), root_path.c_str());
         return nullptr;
@@ -729,23 +710,20 @@
 
     const base::Value* value = nullptr;
     if (!root->GetWithoutPathExpansion(element.first, &value)) {
-      Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
-                         errors::commands::kPropertyMissing,
+      Error::AddToPrintf(error, FROM_HERE, errors::commands::kPropertyMissing,
                          "Component '%s' does not exist at '%s'",
                          element.first.c_str(), root_path.c_str());
       return nullptr;
     }
 
     if (value->GetType() == base::Value::TYPE_LIST && array_index < 0) {
-      Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
-                         errors::commands::kTypeMismatch,
+      Error::AddToPrintf(error, FROM_HERE, errors::commands::kTypeMismatch,
                          "Element '%s.%s' is an array", root_path.c_str(),
                          element.first.c_str());
       return nullptr;
     }
     if (value->GetType() == base::Value::TYPE_DICTIONARY && array_index >= 0) {
-      Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
-                         errors::commands::kTypeMismatch,
+      Error::AddToPrintf(error, FROM_HERE, errors::commands::kTypeMismatch,
                          "Element '%s.%s' is not an array", root_path.c_str(),
                          element.first.c_str());
       return nullptr;
@@ -759,8 +737,7 @@
       const base::Value* component_value = nullptr;
       if (!component_array->Get(array_index, &component_value) ||
           !component_value->GetAsDictionary(&root)) {
-        Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
-                           errors::commands::kPropertyMissing,
+        Error::AddToPrintf(error, FROM_HERE, errors::commands::kPropertyMissing,
                            "Element '%s.%s' does not contain item #%d",
                            root_path.c_str(), element.first.c_str(),
                            array_index);