platform2: Move Error class from Buffet to libchromeos

Moved buffet::Error class and related facilities to
libchromeos and changed the namespace to 'chromeos::'.
Updated a bunch of code to include the header files
from the new location and referring to the new
namespace.

BUG=chromium:403604
TEST=USE=buffet ./build_packages
     FEATURES=test emerge-link libchromeos
     USE=buffet FEATURES=test emerge-link platform2

Change-Id: I0b5b37ccd7ee3b7be9467ebfae5d172d9b057cf6
Reviewed-on: https://chromium-review.googlesource.com/212525
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Reviewed-by: Christopher Wiley <wiley@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/buffet/commands/command_dictionary.cc b/buffet/commands/command_dictionary.cc
index e011a23..64f47c1 100644
--- a/buffet/commands/command_dictionary.cc
+++ b/buffet/commands/command_dictionary.cc
@@ -25,7 +25,7 @@
 bool CommandDictionary::LoadCommands(const base::DictionaryValue& json,
                                      const std::string& category,
                                      const CommandDictionary* base_commands,
-                                     ErrorPtr* error) {
+                                     chromeos::ErrorPtr* error) {
   std::map<std::string, std::shared_ptr<const CommandDefinition>> new_defs;
 
   // |json| contains a list of nested objects with the following structure:
@@ -36,10 +36,10 @@
     std::string package_name = package_iter.key();
     const base::DictionaryValue* package_value = nullptr;
     if (!package_iter.value().GetAsDictionary(&package_value)) {
-      Error::AddToPrintf(error, errors::commands::kDomain,
-                         errors::commands::kTypeMismatch,
-                         "Expecting an object for package '%s'",
-                         package_name.c_str());
+      chromeos::Error::AddToPrintf(error, errors::commands::kDomain,
+                                   errors::commands::kTypeMismatch,
+                                   "Expecting an object for package '%s'",
+                                   package_name.c_str());
       return false;
     }
     // Iterate over command definitions within the current package.
@@ -47,18 +47,19 @@
     while (!command_iter.IsAtEnd()) {
       std::string command_name = command_iter.key();
       if (command_name.empty()) {
-        Error::AddToPrintf(error, errors::commands::kDomain,
-                           errors::commands::kInvalidCommandName,
-                           "Unnamed command encountered in package '%s'",
-                           package_name.c_str());
+        chromeos::Error::AddToPrintf(
+            error, errors::commands::kDomain,
+            errors::commands::kInvalidCommandName,
+            "Unnamed command encountered in package '%s'",
+            package_name.c_str());
         return false;
       }
       const base::DictionaryValue* command_value = nullptr;
       if (!command_iter.value().GetAsDictionary(&command_value)) {
-        Error::AddToPrintf(error, errors::commands::kDomain,
-                           errors::commands::kTypeMismatch,
-                           "Expecting an object for command '%s'",
-                           command_name.c_str());
+        chromeos::Error::AddToPrintf(error, errors::commands::kDomain,
+                                     errors::commands::kTypeMismatch,
+                                     "Expecting an object for command '%s'",
+                                     command_name.c_str());
         return false;
       }
       // Construct the compound command name as "pkg_name.cmd_name".
@@ -69,11 +70,12 @@
       const base::DictionaryValue* command_schema_def = nullptr;
       if (!command_value->GetDictionaryWithoutPathExpansion(
           commands::attributes::kCommand_Parameters, &command_schema_def)) {
-        Error::AddToPrintf(error, errors::commands::kDomain,
-                           errors::commands::kPropertyMissing,
-                           "Command definition '%s' is missing property '%s'",
-                           full_command_name.c_str(),
-                           commands::attributes::kCommand_Parameters);
+        chromeos::Error::AddToPrintf(
+            error, errors::commands::kDomain,
+            errors::commands::kPropertyMissing,
+            "Command definition '%s' is missing property '%s'",
+            full_command_name.c_str(),
+            commands::attributes::kCommand_Parameters);
         return false;
       }
 
@@ -90,11 +92,12 @@
         // this rule here.
         if (!base_def) {
           if (command_name.front() != '_') {
-            Error::AddToPrintf(error, errors::commands::kDomain,
-                               errors::commands::kInvalidCommandName,
-                               "The name of custom command '%s' in package '%s'"
-                               " must start with '_'",
-                               command_name.c_str(), package_name.c_str());
+            chromeos::Error::AddToPrintf(
+                error, errors::commands::kDomain,
+                errors::commands::kInvalidCommandName,
+                "The name of custom command '%s' in package '%s'"
+                " must start with '_'",
+                command_name.c_str(), package_name.c_str());
             return false;
           }
         }
@@ -102,10 +105,10 @@
 
       auto command_schema = std::make_shared<ObjectSchema>();
       if (!command_schema->FromJson(command_schema_def, base_def, error)) {
-        Error::AddToPrintf(error, errors::commands::kDomain,
-                           errors::commands::kInvalidObjectSchema,
-                           "Invalid definition for command '%s'",
-                           full_command_name.c_str());
+        chromeos::Error::AddToPrintf(error, errors::commands::kDomain,
+                                     errors::commands::kInvalidObjectSchema,
+                                     "Invalid definition for command '%s'",
+                                     full_command_name.c_str());
         return false;
       }
       auto command_def = std::make_shared<CommandDefinition>(category,
@@ -124,12 +127,12 @@
   for (const auto& pair : new_defs) {
     auto iter = definitions_.find(pair.first);
     if (iter != definitions_.end()) {
-        Error::AddToPrintf(error, errors::commands::kDomain,
-                           errors::commands::kDuplicateCommandDef,
-                           "Definition for command '%s' overrides an earlier "
-                           "definition in category '%s'",
-                           pair.first.c_str(),
-                           iter->second->GetCategory().c_str());
+        chromeos::Error::AddToPrintf(
+            error, errors::commands::kDomain,
+            errors::commands::kDuplicateCommandDef,
+            "Definition for command '%s' overrides an earlier "
+            "definition in category '%s'",
+            pair.first.c_str(), iter->second->GetCategory().c_str());
         return false;
     }
   }
@@ -146,7 +149,7 @@
 }
 
 std::unique_ptr<base::DictionaryValue> CommandDictionary::GetCommandsAsJson(
-    bool full_schema, ErrorPtr* error) const {
+    bool full_schema, chromeos::ErrorPtr* error) const {
   std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
   for (const auto& pair : definitions_) {
     std::unique_ptr<base::DictionaryValue> definition =
diff --git a/buffet/commands/command_dictionary.h b/buffet/commands/command_dictionary.h
index b656684..10a4f9d 100644
--- a/buffet/commands/command_dictionary.h
+++ b/buffet/commands/command_dictionary.h
@@ -11,8 +11,7 @@
 #include <vector>
 
 #include <base/basictypes.h>
-
-#include "buffet/error.h"
+#include <chromeos/error.h>
 
 namespace base {
 class Value;
@@ -53,14 +52,15 @@
   // when provided.
   bool LoadCommands(const base::DictionaryValue& json,
                     const std::string& category,
-                    const CommandDictionary* base_commands, ErrorPtr* error);
+                    const CommandDictionary* base_commands,
+                    chromeos::ErrorPtr* error);
   // Converts all the command definitions to a JSON object for CDD/Device
   // draft. |full_schema| specifies whether full command definitions must
   // be generated (true) for CDD or only overrides from the base schema (false).
   // Returns empty unique_ptr in case of an error and fills in the additional
   // error details in |error|.
   std::unique_ptr<base::DictionaryValue> GetCommandsAsJson(
-      bool full_schema, ErrorPtr* error) const;
+      bool full_schema, chromeos::ErrorPtr* error) const;
   // Returns the number of command definitions in the dictionary.
   size_t GetSize() const { return definitions_.size(); }
   // Checks if the dictionary has no command definitions.
diff --git a/buffet/commands/command_dictionary_unittest.cc b/buffet/commands/command_dictionary_unittest.cc
index 30d185f..d4c4ab1 100644
--- a/buffet/commands/command_dictionary_unittest.cc
+++ b/buffet/commands/command_dictionary_unittest.cc
@@ -53,7 +53,7 @@
 
 TEST(CommandDictionary, LoadCommands_Failures) {
   buffet::CommandDictionary dict;
-  buffet::ErrorPtr error;
+  chromeos::ErrorPtr error;
 
   // Command definition missing 'parameters' property.
   auto json = CreateDictionaryValue("{'robot':{'jump':{}}}");
@@ -97,7 +97,7 @@
 TEST(CommandDictionary, LoadCommands_RedefineInDifferentCategory) {
   // Redefine commands in different category.
   buffet::CommandDictionary dict;
-  buffet::ErrorPtr error;
+  chromeos::ErrorPtr error;
   auto json = CreateDictionaryValue("{'robot':{'jump':{'parameters':{}}}}");
   dict.LoadCommands(*json, "category1", nullptr, &error);
   EXPECT_FALSE(dict.LoadCommands(*json, "category2", nullptr, &error));
@@ -111,7 +111,7 @@
   // Custom command must start with '_'.
   buffet::CommandDictionary base_dict;
   buffet::CommandDictionary dict;
-  buffet::ErrorPtr error;
+  chromeos::ErrorPtr error;
   auto json = CreateDictionaryValue(R"({
     'base': {
       'reboot': {
@@ -137,7 +137,7 @@
   // Redefine commands parameter type.
   buffet::CommandDictionary base_dict;
   buffet::CommandDictionary dict;
-  buffet::ErrorPtr error;
+  chromeos::ErrorPtr error;
   auto json = CreateDictionaryValue(R"({
     'base': {
       'reboot': {
diff --git a/buffet/commands/command_instance.cc b/buffet/commands/command_instance.cc
index 1e667fe..04b08ab 100644
--- a/buffet/commands/command_instance.cc
+++ b/buffet/commands/command_instance.cc
@@ -5,12 +5,13 @@
 #include "buffet/commands/command_instance.h"
 
 #include <base/values.h>
+#include <chromeos/error.h>
+#include <chromeos/error_codes.h>
 
 #include "buffet/commands/command_definition.h"
 #include "buffet/commands/command_dictionary.h"
 #include "buffet/commands/schema_constants.h"
 #include "buffet/commands/schema_utils.h"
-#include "buffet/error_codes.h"
 
 namespace buffet {
 
@@ -40,7 +41,7 @@
 bool GetCommandParameters(const base::DictionaryValue* json,
                           const CommandDefinition* command_def,
                           native_types::Object* parameters,
-                          ErrorPtr* error) {
+                          chromeos::ErrorPtr* error) {
   // Get the command parameters from 'parameters' property.
   base::DictionaryValue no_params;  // Placeholder when no params are specified.
   const base::DictionaryValue* params = nullptr;
@@ -49,10 +50,10 @@
                                     &params_value)) {
     // Make sure the "parameters" property is actually an object.
     if (!params_value->GetAsDictionary(&params)) {
-      Error::AddToPrintf(error, errors::json::kDomain,
-                         errors::json::kObjectExpected,
-                         "Property '%s' must be a JSON object",
-                         commands::attributes::kCommand_Parameters);
+      chromeos::Error::AddToPrintf(error, chromeos::errors::json::kDomain,
+                                   chromeos::errors::json::kObjectExpected,
+                                   "Property '%s' must be a JSON object",
+                                   commands::attributes::kCommand_Parameters);
       return false;
     }
   } else {
@@ -74,13 +75,14 @@
 std::unique_ptr<const CommandInstance> CommandInstance::FromJson(
     const base::Value* value,
     const CommandDictionary& dictionary,
-    ErrorPtr* error) {
+    chromeos::ErrorPtr* error) {
   std::unique_ptr<const CommandInstance> instance;
   // Get the command JSON object from the value.
   const base::DictionaryValue* json = nullptr;
   if (!value->GetAsDictionary(&json)) {
-    Error::AddTo(error, errors::json::kDomain, errors::json::kObjectExpected,
-                 "Command instance is not a JSON object");
+    chromeos::Error::AddTo(error, chromeos::errors::json::kDomain,
+                           chromeos::errors::json::kObjectExpected,
+                           "Command instance is not a JSON object");
     return instance;
   }
 
@@ -88,25 +90,27 @@
   std::string command_name;
   if (!json->GetStringWithoutPathExpansion(commands::attributes::kCommand_Name,
                                            &command_name)) {
-    Error::AddTo(error, errors::commands::kDomain,
-                 errors::commands::kPropertyMissing,
-                 "Command name is missing");
+    chromeos::Error::AddTo(error, errors::commands::kDomain,
+                           errors::commands::kPropertyMissing,
+                           "Command name is missing");
     return instance;
   }
   // Make sure we know how to handle the command with this name.
   const CommandDefinition* command_def = dictionary.FindCommand(command_name);
   if (!command_def) {
-    Error::AddToPrintf(error, errors::commands::kDomain,
-                       errors::commands::kInvalidCommandName,
-                       "Unknown command received: %s", command_name.c_str());
+    chromeos::Error::AddToPrintf(error, errors::commands::kDomain,
+                                 errors::commands::kInvalidCommandName,
+                                 "Unknown command received: %s",
+                                 command_name.c_str());
     return instance;
   }
 
   native_types::Object parameters;
   if (!GetCommandParameters(json, command_def, &parameters, error)) {
-    Error::AddToPrintf(error, errors::commands::kDomain,
-                       errors::commands::kCommandFailed,
-                       "Failed to validate command '%s'", command_name.c_str());
+    chromeos::Error::AddToPrintf(error, errors::commands::kDomain,
+                                 errors::commands::kCommandFailed,
+                                 "Failed to validate command '%s'",
+                                 command_name.c_str());
     return instance;
   }
 
diff --git a/buffet/commands/command_instance.h b/buffet/commands/command_instance.h
index f5d259d..a901380 100644
--- a/buffet/commands/command_instance.h
+++ b/buffet/commands/command_instance.h
@@ -10,10 +10,10 @@
 #include <string>
 
 #include <base/basictypes.h>
+#include <chromeos/error.h>
 
 #include "buffet/commands/prop_values.h"
 #include "buffet/commands/schema_utils.h"
-#include "buffet/error.h"
 
 namespace base {
 class Value;
@@ -49,7 +49,7 @@
   static std::unique_ptr<const CommandInstance> FromJson(
       const base::Value* value,
       const CommandDictionary& dictionary,
-      ErrorPtr* error);
+      chromeos::ErrorPtr* error);
 
  private:
   // Full command name as "<package_name>.<command_name>".
diff --git a/buffet/commands/command_instance_unittest.cc b/buffet/commands/command_instance_unittest.cc
index 3f81016..ace0738 100644
--- a/buffet/commands/command_instance_unittest.cc
+++ b/buffet/commands/command_instance_unittest.cc
@@ -104,7 +104,7 @@
 
 TEST_F(CommandInstanceTest, FromJson_NotObject) {
   auto json = CreateValue("'string'");
-  buffet::ErrorPtr error;
+  chromeos::ErrorPtr error;
   auto instance = buffet::CommandInstance::FromJson(json.get(), dict_, &error);
   EXPECT_EQ(nullptr, instance.get());
   EXPECT_EQ("json_object_expected", error->GetCode());
@@ -113,7 +113,7 @@
 
 TEST_F(CommandInstanceTest, FromJson_NameMissing) {
   auto json = CreateDictionaryValue("{'param': 'value'}");
-  buffet::ErrorPtr error;
+  chromeos::ErrorPtr error;
   auto instance = buffet::CommandInstance::FromJson(json.get(), dict_, &error);
   EXPECT_EQ(nullptr, instance.get());
   EXPECT_EQ("parameter_missing", error->GetCode());
@@ -122,7 +122,7 @@
 
 TEST_F(CommandInstanceTest, FromJson_UnknownCommand) {
   auto json = CreateDictionaryValue("{'name': 'robot.scream'}");
-  buffet::ErrorPtr error;
+  chromeos::ErrorPtr error;
   auto instance = buffet::CommandInstance::FromJson(json.get(), dict_, &error);
   EXPECT_EQ(nullptr, instance.get());
   EXPECT_EQ("invalid_command_name", error->GetCode());
@@ -134,7 +134,7 @@
     'name': 'robot.speak',
     'parameters': 'hello'
   })");
-  buffet::ErrorPtr error;
+  chromeos::ErrorPtr error;
   auto instance = buffet::CommandInstance::FromJson(json.get(), dict_, &error);
   EXPECT_EQ(nullptr, instance.get());
   auto inner = error->GetInnerError();
@@ -152,7 +152,7 @@
       'volume': 20
     }
   })");
-  buffet::ErrorPtr error;
+  chromeos::ErrorPtr error;
   auto instance = buffet::CommandInstance::FromJson(json.get(), dict_, &error);
   EXPECT_EQ(nullptr, instance.get());
   auto first = error->GetFirstError();
diff --git a/buffet/commands/command_manager.cc b/buffet/commands/command_manager.cc
index 8c54e51..6ba498e 100644
--- a/buffet/commands/command_manager.cc
+++ b/buffet/commands/command_manager.cc
@@ -8,9 +8,10 @@
 #include <base/files/file_enumerator.h>
 #include <base/json/json_reader.h>
 #include <base/values.h>
+#include <chromeos/error.h>
+#include <chromeos/error_codes.h>
 
 #include "buffet/commands/schema_constants.h"
-#include "buffet/error_codes.h"
 
 namespace buffet {
 
@@ -19,12 +20,12 @@
 }
 
 bool CommandManager::LoadBaseCommands(const base::DictionaryValue& json,
-                                      ErrorPtr* error) {
+                                      chromeos::ErrorPtr* error) {
   return base_dictionary_.LoadCommands(json, "", nullptr, error);
 }
 
 bool CommandManager::LoadBaseCommands(const base::FilePath& json_file_path,
-                                      ErrorPtr* error) {
+                                      chromeos::ErrorPtr* error) {
   std::unique_ptr<const base::DictionaryValue> json = LoadJsonDict(
       json_file_path, error);
   if (!json)
@@ -34,12 +35,12 @@
 
 bool CommandManager::LoadCommands(const base::DictionaryValue& json,
                                   const std::string& category,
-                                  ErrorPtr* error) {
+                                  chromeos::ErrorPtr* error) {
   return dictionary_.LoadCommands(json, category, &base_dictionary_, error);
 }
 
 bool CommandManager::LoadCommands(const base::FilePath& json_file_path,
-                                  ErrorPtr* error) {
+                                  chromeos::ErrorPtr* error) {
   std::unique_ptr<const base::DictionaryValue> json = LoadJsonDict(
       json_file_path, error);
   if (!json)
@@ -71,31 +72,33 @@
 }
 
 std::unique_ptr<const base::DictionaryValue> CommandManager::LoadJsonDict(
-    const base::FilePath& json_file_path, ErrorPtr* error) {
+    const base::FilePath& json_file_path, chromeos::ErrorPtr* error) {
   std::string json_string;
   if (!base::ReadFileToString(json_file_path, &json_string)) {
-    Error::AddToPrintf(error, errors::file_system::kDomain,
-                       errors::file_system::kFileReadError,
-                       "Failed to read file '%s'",
-                       json_file_path.value().c_str());
+    chromeos::Error::AddToPrintf(error, chromeos::errors::file_system::kDomain,
+                                 chromeos::errors::file_system::kFileReadError,
+                                 "Failed to read file '%s'",
+                                 json_file_path.value().c_str());
     return std::unique_ptr<const base::DictionaryValue>();
   }
   std::string error_message;
   base::Value* value = base::JSONReader::ReadAndReturnError(
       json_string, base::JSON_PARSE_RFC, nullptr, &error_message);
   if (!value) {
-    Error::AddToPrintf(error, errors::json::kDomain, errors::json::kParseError,
-                       "Error parsing content of JSON file '%s': %s",
-                       json_file_path.value().c_str(), error_message.c_str());
+    chromeos::Error::AddToPrintf(error, chromeos::errors::json::kDomain,
+                                 chromeos::errors::json::kParseError,
+                                 "Error parsing content of JSON file '%s': %s",
+                                 json_file_path.value().c_str(),
+                                 error_message.c_str());
     return std::unique_ptr<const base::DictionaryValue>();
   }
   const base::DictionaryValue* dict_value = nullptr;
   if (!value->GetAsDictionary(&dict_value)) {
     delete value;
-    Error::AddToPrintf(error, errors::json::kDomain,
-                       errors::json::kObjectExpected,
-                       "Content of file '%s' is not a JSON object",
-                       json_file_path.value().c_str());
+    chromeos::Error::AddToPrintf(error, chromeos::errors::json::kDomain,
+                                 chromeos::errors::json::kObjectExpected,
+                                 "Content of file '%s' is not a JSON object",
+                                 json_file_path.value().c_str());
     return std::unique_ptr<const base::DictionaryValue>();
   }
   return std::unique_ptr<const base::DictionaryValue>(dict_value);
diff --git a/buffet/commands/command_manager.h b/buffet/commands/command_manager.h
index 1199892..d3f9a34 100644
--- a/buffet/commands/command_manager.h
+++ b/buffet/commands/command_manager.h
@@ -32,25 +32,26 @@
   // On success, returns true. Otherwise, |error| contains additional
   // error information.
   bool LoadBaseCommands(const base::DictionaryValue& json,
-                        ErrorPtr* error);
+                        chromeos::ErrorPtr* error);
 
   // Same as the overload above, but takes a path to a json file to read
   // the base command definitions from.
   bool LoadBaseCommands(const base::FilePath& json_file_path,
-                        ErrorPtr* error);
+                        chromeos::ErrorPtr* error);
 
   // Loads device command schema for particular category.
   // See CommandDictionary::LoadCommands for detailed description of the
   // parameters.
   bool LoadCommands(const base::DictionaryValue& json,
-                    const std::string& category, ErrorPtr* error);
+                    const std::string& category,
+                    chromeos::ErrorPtr* error);
 
   // Same as the overload above, but takes a path to a json file to read
   // the base command definitions from. Also, the command category is
   // derived from file name (without extension). So, if the path points to
   // "power_manager.json", the command category used will be "power_manager".
   bool LoadCommands(const base::FilePath& json_file_path,
-                    ErrorPtr* error);
+                    chromeos::ErrorPtr* error);
 
   // Startup method to be called by buffet daemon at startup.
   // Initializes the object and loads the standard GCD command
@@ -63,7 +64,7 @@
   // an object/dictionary. In case of error, returns empty unique ptr and fills
   // in error details in |error|.
   std::unique_ptr<const base::DictionaryValue> LoadJsonDict(
-      const base::FilePath& json_file_path, ErrorPtr* error);
+      const base::FilePath& json_file_path, chromeos::ErrorPtr* error);
 
   CommandDictionary base_dictionary_;  // Base/std command definitions/schemas.
   CommandDictionary dictionary_;  // Command definitions/schemas.
diff --git a/buffet/commands/object_schema.cc b/buffet/commands/object_schema.cc
index 82d1e6e..b71b467 100644
--- a/buffet/commands/object_schema.cc
+++ b/buffet/commands/object_schema.cc
@@ -27,7 +27,7 @@
 }
 
 std::unique_ptr<base::DictionaryValue> ObjectSchema::ToJson(
-    bool full_schema, ErrorPtr* error) const {
+    bool full_schema, chromeos::ErrorPtr* error) const {
   std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue);
   for (const auto& pair : properties_) {
     auto PropDef = pair.second->ToJson(full_schema, error);
@@ -40,7 +40,7 @@
 
 bool ObjectSchema::FromJson(const base::DictionaryValue* value,
                             const ObjectSchema* object_schema,
-                            ErrorPtr* error) {
+                            chromeos::ErrorPtr* error) {
   Properties properties;
   base::DictionaryValue::Iterator iter(*value);
   while (!iter.IsAtEnd()) {
@@ -58,26 +58,26 @@
 
 static std::unique_ptr<PropType> CreatePropType(const std::string& type_name,
                                                 const std::string& prop_name,
-                                                ErrorPtr* error) {
+                                                chromeos::ErrorPtr* error) {
   std::unique_ptr<PropType> prop;
   ValueType type;
   if (PropType::GetTypeFromTypeString(type_name, &type))
     prop = PropType::Create(type);
   if (!prop) {
-    Error::AddToPrintf(error, errors::commands::kDomain,
-                       errors::commands::kUnknownType,
-                       "Unknown type %s for parameter %s",
-                       type_name.c_str(), prop_name.c_str());
+    chromeos::Error::AddToPrintf(error, errors::commands::kDomain,
+                                 errors::commands::kUnknownType,
+                                 "Unknown type %s for parameter %s",
+                                 type_name.c_str(), prop_name.c_str());
   }
   return prop;
 }
 
 static bool ErrorInvalidTypeInfo(const std::string& prop_name,
-                                 ErrorPtr* error) {
-  Error::AddToPrintf(error, errors::commands::kDomain,
-                     errors::commands::kNoTypeInfo,
-                     "Unable to determine parameter type for %s",
-                     prop_name.c_str());
+                                 chromeos::ErrorPtr* error) {
+  chromeos::Error::AddToPrintf(error, errors::commands::kDomain,
+                               errors::commands::kNoTypeInfo,
+                               "Unable to determine parameter type for %s",
+                               prop_name.c_str());
   return false;
 }
 
@@ -85,7 +85,7 @@
                                 const base::Value& value,
                                 const PropType* base_schema,
                                 Properties* properties,
-                                ErrorPtr* error) const {
+                                chromeos::ErrorPtr* error) const {
   if (value.IsType(base::Value::TYPE_STRING)) {
     // A string value is a short-hand object specification and provides
     // the parameter type.
@@ -100,9 +100,10 @@
     return PropFromJsonObject(prop_name, value, base_schema, properties,
                               error);
   }
-  Error::AddToPrintf(error, errors::commands::kDomain,
-                     errors::commands::kInvalidPropDef,
-                     "Invalid parameter definition for %s", prop_name.c_str());
+  chromeos::Error::AddToPrintf(error, errors::commands::kDomain,
+                               errors::commands::kInvalidPropDef,
+                               "Invalid parameter definition for %s",
+                               prop_name.c_str());
   return false;
 }
 
@@ -110,7 +111,7 @@
                                       const base::Value& value,
                                       const PropType* base_schema,
                                       Properties* properties,
-                                      ErrorPtr* error) const {
+                                      chromeos::ErrorPtr* error) const {
   std::string type_name;
   CHECK(value.GetAsString(&type_name)) << "Unable to get string value";
   std::unique_ptr<PropType> prop = CreatePropType(type_name, prop_name, error);
@@ -118,10 +119,10 @@
     return false;
   base::DictionaryValue empty;
   if (!prop->FromJson(&empty, base_schema, error)) {
-    Error::AddToPrintf(error, errors::commands::kDomain,
-                       errors::commands::kInvalidPropDef,
-                       "Error in definition of property '%s'",
-                       prop_name.c_str());
+    chromeos::Error::AddToPrintf(error, errors::commands::kDomain,
+                                 errors::commands::kInvalidPropDef,
+                                 "Error in definition of property '%s'",
+                                 prop_name.c_str());
     return false;
   }
   properties->insert(std::make_pair(prop_name, std::move(prop)));
@@ -165,7 +166,7 @@
                                      const base::Value& value,
                                      const PropType* base_schema,
                                      Properties* properties,
-                                     ErrorPtr* error) const {
+                                     chromeos::ErrorPtr* error) const {
   const base::ListValue* list = nullptr;
   CHECK(value.GetAsList(&list)) << "Unable to get array value";
   std::string type_name = DetectArrayType(list, base_schema);
@@ -178,10 +179,10 @@
   array_object.SetWithoutPathExpansion(commands::attributes::kOneOf_Enum,
                                        list->DeepCopy());
   if (!prop->FromJson(&array_object, base_schema, error)) {
-    Error::AddToPrintf(error, errors::commands::kDomain,
-                       errors::commands::kInvalidPropDef,
-                       "Error in definition of property '%s'",
-                       prop_name.c_str());
+    chromeos::Error::AddToPrintf(error, errors::commands::kDomain,
+                                 errors::commands::kInvalidPropDef,
+                                 "Error in definition of property '%s'",
+                                 prop_name.c_str());
     return false;
   }
   properties->insert(std::make_pair(prop_name, std::move(prop)));
@@ -242,7 +243,7 @@
                                       const base::Value& value,
                                       const PropType* base_schema,
                                       Properties* properties,
-                                      ErrorPtr* error) const {
+                                      chromeos::ErrorPtr* error) const {
   const base::DictionaryValue* dict = nullptr;
   CHECK(value.GetAsDictionary(&dict)) << "Unable to get dictionary value";
   std::string type_name;
@@ -261,10 +262,10 @@
   if (!prop)
     return false;
   if (!prop->FromJson(dict, base_schema, error)) {
-    Error::AddToPrintf(error, errors::commands::kDomain,
-                       errors::commands::kInvalidPropDef,
-                       "Error in definition of property '%s'",
-                       prop_name.c_str());
+    chromeos::Error::AddToPrintf(error, errors::commands::kDomain,
+                                 errors::commands::kInvalidPropDef,
+                                 "Error in definition of property '%s'",
+                                 prop_name.c_str());
     return false;
   }
   properties->insert(std::make_pair(prop_name, std::move(prop)));
diff --git a/buffet/commands/object_schema.h b/buffet/commands/object_schema.h
index d6f5069..d133b1a 100644
--- a/buffet/commands/object_schema.h
+++ b/buffet/commands/object_schema.h
@@ -9,7 +9,7 @@
 #include <memory>
 #include <string>
 
-#include "buffet/error.h"
+#include <chromeos/error.h>
 
 namespace base {
 class Value;
@@ -58,37 +58,40 @@
   // Saves the object schema to JSON. When |full_schema| is set to true,
   // then all properties and constraints are saved, otherwise, only
   // the overridden (not inherited) ones are saved.
-  std::unique_ptr<base::DictionaryValue> ToJson(bool full_schema,
-                                                ErrorPtr* error) const;
+  std::unique_ptr<base::DictionaryValue> ToJson(
+      bool full_schema, chromeos::ErrorPtr* error) const;
   // Loads the object schema from JSON. If |object_schema| is not nullptr, it is
   // used as a base schema to inherit omitted properties and constraints from.
   bool FromJson(const base::DictionaryValue* value,
-                const ObjectSchema* object_schema, ErrorPtr* error);
+                const ObjectSchema* object_schema, chromeos::ErrorPtr* error);
 
  private:
   // Internal helper method to load individual parameter type definitions.
   bool PropFromJson(const std::string& prop_name,
                     const base::Value& value,
                     const PropType* base_schema,
-                    Properties* properties, ErrorPtr* error) const;
+                    Properties* properties, chromeos::ErrorPtr* error) const;
   // Helper function in case the parameter is defined as JSON string like this:
   //   "prop":"..."
   bool PropFromJsonString(const std::string& prop_name,
                           const base::Value& value,
                           const PropType* base_schema,
-                          Properties* properties, ErrorPtr* error) const;
+                          Properties* properties,
+                          chromeos::ErrorPtr* error) const;
   // Helper function in case the parameter is defined as JSON array like this:
   //   "prop":[...]
   bool PropFromJsonArray(const std::string& prop_name,
                          const base::Value& value,
                          const PropType* base_schema,
-                         Properties* properties, ErrorPtr* error) const;
+                         Properties* properties,
+                         chromeos::ErrorPtr* error) const;
   // Helper function in case the parameter is defined as JSON object like this:
   //   "prop":{...}
   bool PropFromJsonObject(const std::string& prop_name,
                           const base::Value& value,
                           const PropType* base_schema,
-                          Properties* properties, ErrorPtr* error) const;
+                          Properties* properties,
+                          chromeos::ErrorPtr* error) const;
 
   // Internal parameter type definition map.
   Properties properties_;
diff --git a/buffet/commands/object_schema_unittest.cc b/buffet/commands/object_schema_unittest.cc
index 6921b56..e2e32e1 100644
--- a/buffet/commands/object_schema_unittest.cc
+++ b/buffet/commands/object_schema_unittest.cc
@@ -95,7 +95,7 @@
 TEST(CommandSchema, IntPropType_Validate) {
   buffet::IntPropType prop;
   prop.AddMinMaxConstraint(2, 4);
-  buffet::ErrorPtr error;
+  chromeos::ErrorPtr error;
   EXPECT_FALSE(prop.ValidateValue(CreateValue("-1").get(), &error));
   EXPECT_EQ("out_of_range", error->GetCode());
   error.reset();
@@ -172,7 +172,7 @@
   buffet::BooleanPropType prop;
   prop.FromJson(CreateDictionaryValue("{'enum':[true]}").get(), &prop,
                 nullptr);
-  buffet::ErrorPtr error;
+  chromeos::ErrorPtr error;
   EXPECT_FALSE(prop.ValidateValue(CreateValue("false").get(), &error));
   EXPECT_EQ("out_of_range", error->GetCode());
   error.reset();
@@ -262,7 +262,7 @@
 TEST(CommandSchema, DoublePropType_Validate) {
   buffet::DoublePropType prop;
   prop.AddMinMaxConstraint(-1.2, 1.3);
-  buffet::ErrorPtr error;
+  chromeos::ErrorPtr error;
   EXPECT_FALSE(prop.ValidateValue(CreateValue("-2").get(), &error));
   EXPECT_EQ("out_of_range", error->GetCode());
   error.reset();
@@ -359,7 +359,7 @@
 TEST(CommandSchema, StringPropType_Validate) {
   buffet::StringPropType prop;
   prop.AddLengthConstraint(1, 3);
-  buffet::ErrorPtr error;
+  chromeos::ErrorPtr error;
   EXPECT_FALSE(prop.ValidateValue(CreateValue("''").get(), &error));
   EXPECT_EQ("out_of_range", error->GetCode());
   error.reset();
@@ -450,7 +450,7 @@
       "{'properties':{'expires':'integer',"
       "'password':{'maxLength':100,'minLength':6}}}").get(), nullptr,
       nullptr);
-  buffet::ErrorPtr error;
+  chromeos::ErrorPtr error;
   EXPECT_TRUE(prop.ValidateValue(CreateValue(
       "{'expires':10,'password':'abcdef'}").get(), &error));
   error.reset();
@@ -486,7 +486,7 @@
       "{'properties':{'width':'integer','height':'integer'},"
       "'enum':[{'width':10,'height':20},{'width':100,'height':200}]}").get(),
       nullptr, nullptr));
-  buffet::ErrorPtr error;
+  chromeos::ErrorPtr error;
   EXPECT_TRUE(prop.ValidateValue(CreateValue(
       "{'height':20,'width':10}").get(), &error));
   error.reset();
@@ -790,7 +790,7 @@
 
 TEST(CommandSchema, ObjectSchema_FromJson_BaseSchema_Failures) {
   buffet::ObjectSchema schema;
-  buffet::ErrorPtr error;
+  chromeos::ErrorPtr error;
   const char* schema_str = "{"
   "'param1':{}"
   "}";
diff --git a/buffet/commands/prop_constraints.cc b/buffet/commands/prop_constraints.cc
index 97b524d..210b254 100644
--- a/buffet/commands/prop_constraints.cc
+++ b/buffet/commands/prop_constraints.cc
@@ -12,37 +12,42 @@
 // Constraint ----------------------------------------------------------------
 Constraint::~Constraint() {}
 
-bool Constraint::ReportErrorLessThan(
-    ErrorPtr* error, const std::string& val, const std::string& limit) {
-  Error::AddToPrintf(error, errors::commands::kDomain,
-                     errors::commands::kOutOfRange,
-                     "Value %s is out of range. It must not be less than %s",
-                     val.c_str(), limit.c_str());
+bool Constraint::ReportErrorLessThan(chromeos::ErrorPtr* error,
+                                     const std::string& val,
+                                     const std::string& limit) {
+  chromeos::Error::AddToPrintf(
+      error, errors::commands::kDomain,
+      errors::commands::kOutOfRange,
+      "Value %s is out of range. It must not be less than %s",
+      val.c_str(), limit.c_str());
   return false;
 }
 
-bool Constraint::ReportErrorGreaterThan(
-    ErrorPtr* error, const std::string& val, const std::string& limit) {
-  Error::AddToPrintf(error, errors::commands::kDomain,
-                     errors::commands::kOutOfRange,
-                     "Value %s is out of range. It must not be greater than %s",
-                     val.c_str(), limit.c_str());
+bool Constraint::ReportErrorGreaterThan(chromeos::ErrorPtr* error,
+                                        const std::string& val,
+                                        const std::string& limit) {
+  chromeos::Error::AddToPrintf(
+      error, errors::commands::kDomain,
+      errors::commands::kOutOfRange,
+      "Value %s is out of range. It must not be greater than %s",
+      val.c_str(), limit.c_str());
   return false;
 }
 
-bool Constraint::ReportErrorNotOneOf(
-    ErrorPtr* error, const std::string& val,
-    const std::vector<std::string>& values) {
-  Error::AddToPrintf(error, errors::commands::kDomain,
-                     errors::commands::kOutOfRange,
-                     "Value %s is invalid. Expected one of [%s]",
-                     val.c_str(), string_utils::Join(',', values).c_str());
+bool Constraint::ReportErrorNotOneOf(chromeos::ErrorPtr* error,
+                                     const std::string& val,
+                                     const std::vector<std::string>& values) {
+  chromeos::Error::AddToPrintf(error, errors::commands::kDomain,
+                               errors::commands::kOutOfRange,
+                               "Value %s is invalid. Expected one of [%s]",
+                               val.c_str(),
+                               string_utils::Join(',', values).c_str());
   return false;
 }
 
 bool Constraint::AddToJsonDict(base::DictionaryValue* dict,
                                bool overridden_only,
-                               ErrorPtr* error) const {
+                               chromeos::ErrorPtr* error) const {
   if (!overridden_only || HasOverriddenAttributes()) {
     auto value = ToJson(error);
     if (!value)
@@ -62,7 +67,7 @@
 }
 
 std::unique_ptr<base::Value> ConstraintStringLength::ToJson(
-    ErrorPtr* error) const {
+    chromeos::ErrorPtr* error) const {
   return TypedValueToJson(limit_.value, error);
 }
 
@@ -73,20 +78,21 @@
     : ConstraintStringLength(limit) {}
 
 bool ConstraintStringLengthMin::Validate(const PropValue& value,
-                                         ErrorPtr* error) const {
+                                         chromeos::ErrorPtr* error) const {
   CHECK(value.GetString()) << "Expecting a string value for this constraint";
   const std::string& str = value.GetString()->GetValue();
   int length = static_cast<int>(str.size());
   if (length < limit_.value) {
     if (limit_.value == 1) {
-      Error::AddTo(error, errors::commands::kDomain,
-                   errors::commands::kOutOfRange, "String must not be empty");
+      chromeos::Error::AddTo(error, errors::commands::kDomain,
+                             errors::commands::kOutOfRange,
+                             "String must not be empty");
     } else {
-      Error::AddToPrintf(error, errors::commands::kDomain,
-                         errors::commands::kOutOfRange,
-                         "String must be at least %d characters long, "
-                         "actual length of string '%s' is %d", limit_.value,
-                         str.c_str(), length);
+      chromeos::Error::AddToPrintf(error, errors::commands::kDomain,
+                                   errors::commands::kOutOfRange,
+                                   "String must be at least %d characters long,"
+                                   " actual length of string '%s' is %d",
+                                   limit_.value, str.c_str(), length);
     }
     return false;
   }
@@ -105,16 +111,16 @@
     : ConstraintStringLength(limit) {}
 
 bool ConstraintStringLengthMax::Validate(const PropValue& value,
-                                         ErrorPtr* error) const {
+                                         chromeos::ErrorPtr* error) const {
   CHECK(value.GetString()) << "Expecting a string value for this constraint";
   const std::string& str = value.GetString()->GetValue();
   int length = static_cast<int>(str.size());
   if (length > limit_.value) {
-    Error::AddToPrintf(error, errors::commands::kDomain,
-                       errors::commands::kOutOfRange,
-                       "String must be no more than %d character(s) long, "
-                       "actual length of string '%s' is %d", limit_.value,
-                       str.c_str(), length);
+    chromeos::Error::AddToPrintf(error, errors::commands::kDomain,
+                                 errors::commands::kOutOfRange,
+                                 "String must be no more than %d character(s) "
+                                 "long, actual length of string '%s' is %d",
+                                 limit_.value, str.c_str(), length);
     return false;
   }
   return true;
diff --git a/buffet/commands/prop_constraints.h b/buffet/commands/prop_constraints.h
index cd35d65..3aa6e8e 100644
--- a/buffet/commands/prop_constraints.h
+++ b/buffet/commands/prop_constraints.h
@@ -11,11 +11,11 @@
 
 #include <base/basictypes.h>
 #include <base/values.h>
+#include <chromeos/error.h>
 
 #include "buffet/commands/prop_values.h"
 #include "buffet/commands/schema_constants.h"
 #include "buffet/commands/schema_utils.h"
-#include "buffet/error.h"
 #include "buffet/string_utils.h"
 
 namespace buffet {
@@ -46,7 +46,8 @@
   // Validates a parameter against the constraint. Returns true if parameter
   // value satisfies the constraint, otherwise fills the optional |error| with
   // the details for the failure.
-  virtual bool Validate(const PropValue& value, ErrorPtr* error) const = 0;
+  virtual bool Validate(const PropValue& value,
+                        chromeos::ErrorPtr* error) const = 0;
   // Makes a copy of the constraint object, marking all the attributes
   // as inherited from the original definition.
   virtual std::shared_ptr<Constraint> CloneAsInherited() const = 0;
@@ -54,13 +55,14 @@
   // the object schema. If |overridden_only| is set to true, then the
   // inherited constraints will not be added to the schema object.
   virtual bool AddToJsonDict(base::DictionaryValue* dict, bool overridden_only,
-                             ErrorPtr* error) const;
+                             chromeos::ErrorPtr* error) const;
   // Saves the value of constraint to JSON value. E.g., if the numeric
   // constraint was defined as {"minimum":20} this will create a JSON value
   // of 20. The current design implies that each constraint has one value
   // only. If this assumption changes, this interface needs to be updated
   // accordingly.
-  virtual std::unique_ptr<base::Value> ToJson(ErrorPtr* error) const = 0;
+  virtual std::unique_ptr<base::Value> ToJson(
+      chromeos::ErrorPtr* error) const = 0;
   // Overloaded by the concrete class implementation, it should return the
   // JSON object property name to store the constraint's value as.
   // E.g., if the numeric constraint was defined as {"minimum":20} this
@@ -73,12 +75,15 @@
   // Since these functions could be used by constraint objects for various
   // data types, the values used in validation are expected to be
   // send as strings already.
-  static bool ReportErrorLessThan(ErrorPtr* error, const std::string& val,
+  static bool ReportErrorLessThan(chromeos::ErrorPtr* error,
+                                  const std::string& val,
                                   const std::string& limit);
-  static bool ReportErrorGreaterThan(ErrorPtr* error, const std::string& val,
+  static bool ReportErrorGreaterThan(chromeos::ErrorPtr* error,
+                                     const std::string& val,
                                      const std::string& limit);
 
-  static bool ReportErrorNotOneOf(ErrorPtr* error, const std::string& val,
+  static bool ReportErrorNotOneOf(chromeos::ErrorPtr* error,
+                                  const std::string& val,
                                   const std::vector<std::string>& values);
 
  private:
@@ -101,7 +106,8 @@
   }
 
   // Implementation of Constraint::ToJson().
-  std::unique_ptr<base::Value> ToJson(ErrorPtr* error) const override {
+  std::unique_ptr<base::Value> ToJson(
+      chromeos::ErrorPtr* error) const override {
     return TypedValueToJson(limit_.value, error);
   }
 
@@ -127,7 +133,8 @@
   ConstraintType GetType() const { return ConstraintType::Min; }
 
   // Implementation of Constraint::Validate().
-  bool Validate(const PropValue& value, ErrorPtr* error) const override {
+  bool Validate(const PropValue& value,
+                chromeos::ErrorPtr* error) const override {
     T v = value.GetValueAsAny().Get<T>();
     if (v < this->limit_.value)
       return this->ReportErrorLessThan(
@@ -163,7 +170,8 @@
   ConstraintType GetType() const { return ConstraintType::Max; }
 
   // Implementation of Constraint::Validate().
-  bool Validate(const PropValue& value, ErrorPtr* error) const override {
+  bool Validate(const PropValue& value,
+                chromeos::ErrorPtr* error) const override {
     T v = value.GetValueAsAny().Get<T>();
     if (v > this->limit_.value)
       return this->ReportErrorGreaterThan(
@@ -196,7 +204,7 @@
   // Implementation of Constraint::HasOverriddenAttributes().
   bool HasOverriddenAttributes() const override;
   // Implementation of Constraint::ToJson().
-  std::unique_ptr<base::Value> ToJson(ErrorPtr* error) const override;
+  std::unique_ptr<base::Value> ToJson(chromeos::ErrorPtr* error) const override;
 
   // Stores the upper/lower value limit for string length constraint.
   // |limit_.is_inherited| indicates whether the constraint is inherited
@@ -217,7 +225,8 @@
     return ConstraintType::StringLengthMin;
   }
   // Implementation of Constraint::Validate().
-  bool Validate(const PropValue& value, ErrorPtr* error) const override;
+  bool Validate(const PropValue& value,
+                chromeos::ErrorPtr* error) const override;
   // Implementation of Constraint::CloneAsInherited().
   std::shared_ptr<Constraint> CloneAsInherited() const override;
   // Implementation of Constraint::GetDictKey().
@@ -238,7 +247,8 @@
     return ConstraintType::StringLengthMax;
   }
   // Implementation of Constraint::Validate().
-  bool Validate(const PropValue& value, ErrorPtr* error) const override;
+  bool Validate(const PropValue& value,
+                chromeos::ErrorPtr* error) const override;
   // Implementation of Constraint::CloneAsInherited().
   std::shared_ptr<Constraint> CloneAsInherited() const override;
   // Implementation of Constraint::GetDictKey().
@@ -270,7 +280,8 @@
   }
 
   // Implementation of Constraint::Validate().
-  bool Validate(const PropValue& value, ErrorPtr* error) const override {
+  bool Validate(const PropValue& value,
+                chromeos::ErrorPtr* error) const override {
     using string_utils::ToString;
     T v = value.GetValueAsAny().Get<T>();
     for (const auto& item : set_.value) {
@@ -291,7 +302,8 @@
   }
 
   // Implementation of Constraint::ToJson().
-  std::unique_ptr<base::Value> ToJson(ErrorPtr* error) const override {
+  std::unique_ptr<base::Value> ToJson(
+      chromeos::ErrorPtr* error) const override {
     return TypedValueToJson(set_.value, error);
   }
 
diff --git a/buffet/commands/prop_types.cc b/buffet/commands/prop_types.cc
index f32ff2c..a3d7d6c 100644
--- a/buffet/commands/prop_types.cc
+++ b/buffet/commands/prop_types.cc
@@ -39,7 +39,7 @@
 }
 
 std::unique_ptr<base::Value> PropType::ToJson(bool full_schema,
-                                              ErrorPtr* error) const {
+                                              chromeos::ErrorPtr* error) const {
   if (!full_schema && !HasOverriddenAttributes()) {
     if (based_on_schema_)
       return std::unique_ptr<base::Value>(new base::DictionaryValue);
@@ -82,13 +82,14 @@
 }
 
 bool PropType::FromJson(const base::DictionaryValue* value,
-                        const PropType* base_schema, ErrorPtr* error) {
+                        const PropType* base_schema,
+                        chromeos::ErrorPtr* error) {
   if (base_schema && base_schema->GetType() != GetType()) {
-    Error::AddToPrintf(error, errors::commands::kDomain,
-                       errors::commands::kPropTypeChanged,
-                       "Redefining a property of type %s as %s",
-                       base_schema->GetTypeAsString().c_str(),
-                       GetTypeAsString().c_str());
+    chromeos::Error::AddToPrintf(error, errors::commands::kDomain,
+                                 errors::commands::kPropTypeChanged,
+                                 "Redefining a property of type %s as %s",
+                                 base_schema->GetTypeAsString().c_str(),
+                                 GetTypeAsString().c_str());
     return false;
   }
   based_on_schema_ = (base_schema != nullptr);
@@ -111,9 +112,9 @@
   while (!iter.IsAtEnd()) {
     std::string key = iter.key();
     if (processed_keys.find(key) == processed_keys.end()) {
-      Error::AddToPrintf(error, errors::commands::kDomain,
-                         errors::commands::kUnknownProperty,
-                         "Unexpected property '%s'", key.c_str());
+      chromeos::Error::AddToPrintf(error, errors::commands::kDomain,
+                                   errors::commands::kUnknownProperty,
+                                   "Unexpected property '%s'", key.c_str());
       return false;
     }
     iter.Advance();
@@ -141,14 +142,15 @@
   return p != constraints_.end() ? p->second.get() : nullptr;
 }
 
-bool PropType::ValidateValue(const base::Value* value, ErrorPtr* error) const {
+bool PropType::ValidateValue(const base::Value* value,
+                             chromeos::ErrorPtr* error) const {
   std::shared_ptr<PropValue> val = CreateValue();
   CHECK(val) << "Failed to create value object";
   return val->FromJson(value, error) && ValidateConstraints(*val, error);
 }
 
 bool PropType::ValidateConstraints(const PropValue& value,
-                                   ErrorPtr* error) const {
+                                   chromeos::ErrorPtr* error) const {
   for (const auto& pair : constraints_) {
     if (!pair.second->Validate(value, error))
       return false;
@@ -211,12 +213,13 @@
 template<typename T>
 static std::shared_ptr<Constraint> LoadOneOfConstraint(
     const base::DictionaryValue* value, const ObjectSchema* object_schema,
-    ErrorPtr* error) {
+    chromeos::ErrorPtr* error) {
   const base::ListValue* list = nullptr;
   if (!value->GetListWithoutPathExpansion(commands::attributes::kOneOf_Enum,
                                           &list)) {
-    Error::AddTo(error, errors::commands::kDomain,
-                 errors::commands::kTypeMismatch, "Expecting an array");
+    chromeos::Error::AddTo(error, errors::commands::kDomain,
+                           errors::commands::kTypeMismatch,
+                           "Expecting an array");
     return std::shared_ptr<Constraint>();
   }
   std::vector<T> set;
@@ -234,7 +237,7 @@
 template<class ConstraintClass, typename T>
 static std::shared_ptr<Constraint> LoadMinMaxConstraint(
     const char* dict_key, const base::DictionaryValue* value,
-    const ObjectSchema* object_schema, ErrorPtr* error) {
+    const ObjectSchema* object_schema, chromeos::ErrorPtr* error) {
   InheritableAttribute<T> limit;
 
   const base::Value* src_val = nullptr;
@@ -251,7 +254,7 @@
 template<class Derived, class Value, typename T>
 bool PropTypeBase<Derived, Value, T>::ConstraintsFromJson(
     const base::DictionaryValue* value, std::set<std::string>* processed_keys,
-    ErrorPtr* error) {
+    chromeos::ErrorPtr* error) {
   if (!PropType::ConstraintsFromJson(value, processed_keys, error))
     return false;
 
@@ -274,7 +277,7 @@
 template<class Derived, class Value, typename T>
 bool NumericPropTypeBase<Derived, Value, T>::ConstraintsFromJson(
     const base::DictionaryValue* value, std::set<std::string>* processed_keys,
-    ErrorPtr* error) {
+    chromeos::ErrorPtr* error) {
   if (!_Base::ConstraintsFromJson(value, processed_keys, error))
     return false;
 
@@ -311,7 +314,7 @@
 
 bool StringPropType::ConstraintsFromJson(
     const base::DictionaryValue* value, std::set<std::string>* processed_keys,
-    ErrorPtr* error) {
+    chromeos::ErrorPtr* error) {
   if (!_Base::ConstraintsFromJson(value, processed_keys, error))
     return false;
 
@@ -372,8 +375,8 @@
          !object_schema_.is_inherited;
 }
 
-std::unique_ptr<base::Value> ObjectPropType::ToJson(bool full_schema,
-                                                    ErrorPtr* error) const {
+std::unique_ptr<base::Value> ObjectPropType::ToJson(
+    bool full_schema, chromeos::ErrorPtr* error) const {
   std::unique_ptr<base::Value> value = PropType::ToJson(full_schema, error);
   if (value) {
     base::DictionaryValue* dict = nullptr;
@@ -393,7 +396,7 @@
 
 bool ObjectPropType::ObjectSchemaFromJson(
     const base::DictionaryValue* value, const PropType* base_schema,
-    std::set<std::string>* processed_keys, ErrorPtr* error) {
+    std::set<std::string>* processed_keys, chromeos::ErrorPtr* error) {
   if (!_Base::ObjectSchemaFromJson(value, base_schema, processed_keys, error))
     return false;
 
@@ -408,9 +411,9 @@
     processed_keys->insert(kObject_Properties);
     auto object_schema = std::make_shared<ObjectSchema>();
     if (!object_schema->FromJson(props, base_object_schema.get(), error)) {
-      Error::AddTo(error, errors::commands::kDomain,
-                   errors::commands::kInvalidObjectSchema,
-                   "Error parsing object property schema");
+      chromeos::Error::AddTo(error, errors::commands::kDomain,
+                             errors::commands::kInvalidObjectSchema,
+                             "Error parsing object property schema");
       return false;
     }
     object_schema_.value = object_schema;
@@ -419,10 +422,11 @@
     object_schema_.value = base_object_schema;
     object_schema_.is_inherited = true;
   } else {
-    Error::AddToPrintf(error, errors::commands::kDomain,
-                       errors::commands::kInvalidObjectSchema,
-                       "Object type definition must include the object schema "
-                       "('%s' field not found)", kObject_Properties);
+    chromeos::Error::AddToPrintf(error, errors::commands::kDomain,
+                                 errors::commands::kInvalidObjectSchema,
+                                 "Object type definition must include the "
+                                 "object schema ('%s' field not found)",
+                                 kObject_Properties);
     return false;
   }
 
diff --git a/buffet/commands/prop_types.h b/buffet/commands/prop_types.h
index f7cd5a1..7f2b2e6 100644
--- a/buffet/commands/prop_types.h
+++ b/buffet/commands/prop_types.h
@@ -13,9 +13,10 @@
 #include <utility>
 #include <vector>
 
+#include <chromeos/error.h>
+
 #include "buffet/commands/prop_constraints.h"
 #include "buffet/commands/prop_values.h"
-#include "buffet/error.h"
 
 namespace buffet {
 
@@ -90,7 +91,7 @@
   // If it fails, returns "nullptr" and fills in the |error| with additional
   // error information.
   virtual std::unique_ptr<base::Value> ToJson(bool full_schema,
-                                              ErrorPtr* error) const;
+                                              chromeos::ErrorPtr* error) const;
   // Parses an JSON parameter type definition. Optional |base_schema| may
   // specify the base schema type definition this type should be based upon.
   // If not specified (nullptr), the parameter type is assumed to be a full
@@ -98,18 +99,18 @@
   // Returns true on success, otherwise fills in the |error| with additional
   // error information.
   virtual bool FromJson(const base::DictionaryValue* value,
-                        const PropType* base_schema, ErrorPtr* error);
+                        const PropType* base_schema, chromeos::ErrorPtr* error);
   // Helper function to load object schema from JSON.
   virtual bool ObjectSchemaFromJson(const base::DictionaryValue* value,
                                     const PropType* base_schema,
                                     std::set<std::string>* processed_keys,
-                                    ErrorPtr* error) {
+                                    chromeos::ErrorPtr* error) {
     return true;
   }
   // Helper function to load type-specific constraints from JSON.
   virtual bool ConstraintsFromJson(const base::DictionaryValue* value,
                                    std::set<std::string>* processed_keys,
-                                   ErrorPtr* error) {
+                                   chromeos::ErrorPtr* error) {
     return true;
   }
 
@@ -118,7 +119,7 @@
   // Returns false if the |value| does not meet the requirements of the type
   // definition and returns additional information about the failure via
   // the |error| parameter.
-  bool ValidateValue(const base::Value* value, ErrorPtr* error) const;
+  bool ValidateValue(const base::Value* value, chromeos::ErrorPtr* error) const;
 
   // Additional helper static methods to help with converting a type enum
   // value into a string and back.
@@ -153,7 +154,8 @@
   }
 
   // Validates the given value against all the constraints.
-  bool ValidateConstraints(const PropValue& value, ErrorPtr* error) const;
+  bool ValidateConstraints(const PropValue& value,
+                           chromeos::ErrorPtr* error) const;
 
  protected:
   // Specifies if this parameter definition is derived from a base
@@ -188,7 +190,7 @@
   }
   bool ConstraintsFromJson(const base::DictionaryValue* value,
                            std::set<std::string>* processed_keys,
-                           ErrorPtr* error) override;
+                           chromeos::ErrorPtr* error) override;
 
   // Helper method to obtain a vector of OneOf constraint values.
   std::vector<T> GetOneOfValues() const {
@@ -205,7 +207,7 @@
   using _Base = PropTypeBase<Derived, Value, T>;
   bool ConstraintsFromJson(const base::DictionaryValue* value,
                            std::set<std::string>* processed_keys,
-                           ErrorPtr* error) override;
+                           chromeos::ErrorPtr* error) override;
 
   // Helper method to set and obtain a min/max constraint values.
   // Used mostly for unit testing.
@@ -255,7 +257,7 @@
 
   bool ConstraintsFromJson(const base::DictionaryValue* value,
                            std::set<std::string>* processed_keys,
-                           ErrorPtr* error) override;
+                           chromeos::ErrorPtr* error) override;
 
   // Helper methods to add and inspect simple constraints.
   // Used mostly for unit testing.
@@ -287,11 +289,11 @@
   ObjectPropType const* GetObject() const override { return this; }
 
   std::unique_ptr<base::Value> ToJson(bool full_schema,
-                                      ErrorPtr* error) const override;
+                                      chromeos::ErrorPtr* error) const override;
   bool ObjectSchemaFromJson(const base::DictionaryValue* value,
                             const PropType* base_schema,
                             std::set<std::string>* processed_keys,
-                            ErrorPtr* error) override;
+                            chromeos::ErrorPtr* error) override;
 
   std::shared_ptr<const ObjectSchema> GetObjectSchema() const override {
     return object_schema_.value;
diff --git a/buffet/commands/prop_values.h b/buffet/commands/prop_values.h
index b408f0d..f568dd8 100644
--- a/buffet/commands/prop_values.h
+++ b/buffet/commands/prop_values.h
@@ -9,9 +9,10 @@
 #include <memory>
 #include <string>
 
+#include <chromeos/error.h>
+
 #include "buffet/any.h"
 #include "buffet/commands/schema_utils.h"
-#include "buffet/error.h"
 
 namespace base {
 class Value;
@@ -93,12 +94,13 @@
   // Saves the value as a JSON object.
   // If it fails, returns nullptr value and fills in the details for the
   // failure in the |error| parameter.
-  virtual std::unique_ptr<base::Value> ToJson(ErrorPtr* error) const = 0;
+  virtual std::unique_ptr<base::Value> ToJson(
+      chromeos::ErrorPtr* error) const = 0;
   // Parses a value from JSON.
   // If it fails, it returns false and provides additional information
   // via the |error| parameter.
   virtual bool FromJson(const base::Value* value,
-                        ErrorPtr* error) = 0;
+                        chromeos::ErrorPtr* error) = 0;
 
   // Returns the contained C++ value as Any.
   virtual Any GetValueAsAny() const = 0;
@@ -129,12 +131,12 @@
     return std::make_shared<Derived>(*static_cast<const Derived*>(this));
   }
 
-  std::unique_ptr<base::Value> ToJson(ErrorPtr* error) const override {
+  std::unique_ptr<base::Value> ToJson(
+      chromeos::ErrorPtr* error) const override {
     return TypedValueToJson(value_, error);
   }
 
-  bool FromJson(const base::Value* value,
-                        ErrorPtr* error) override {
+  bool FromJson(const base::Value* value, chromeos::ErrorPtr* error) override {
     return TypedValueFromJson(value, GetPropType()->GetObjectSchemaPtr(),
                               &value_, error);
   }
diff --git a/buffet/commands/schema_utils.cc b/buffet/commands/schema_utils.cc
index cef5030..08b00cb 100644
--- a/buffet/commands/schema_utils.cc
+++ b/buffet/commands/schema_utils.cc
@@ -19,54 +19,58 @@
 // Helper function to report "type mismatch" errors when parsing JSON.
 void ReportJsonTypeMismatch(const base::Value* value_in,
                             const std::string& expected_type,
-                            ErrorPtr* error) {
+                            chromeos::ErrorPtr* error) {
   std::string value_as_string;
   base::JSONWriter::Write(value_in, &value_as_string);
-  Error::AddToPrintf(error, errors::commands::kDomain,
-                     errors::commands::kTypeMismatch,
-                     "Unable to convert value %s into %s",
-                     value_as_string.c_str(), expected_type.c_str());
+  chromeos::Error::AddToPrintf(error, errors::commands::kDomain,
+                               errors::commands::kTypeMismatch,
+                               "Unable to convert value %s into %s",
+                               value_as_string.c_str(), expected_type.c_str());
 }
 
 // Template version of ReportJsonTypeMismatch that deduces the type of expected
 // data from the value_out parameter passed to particular overload of
 // TypedValueFromJson() function. Always returns false.
 template<typename T>
-bool ReportUnexpectedJson(const base::Value* value_in, T*, ErrorPtr* error) {
+bool ReportUnexpectedJson(const base::Value* value_in, T*,
+                          chromeos::ErrorPtr* error) {
   ReportJsonTypeMismatch(value_in,
                          PropType::GetTypeStringFromType(GetValueType<T>()),
                          error);
   return false;
 }
 
-bool ErrorMissingProperty(ErrorPtr* error, const char* param_name) {
-  Error::AddToPrintf(error, errors::commands::kDomain,
-                     errors::commands::kPropertyMissing,
-                     "Required parameter missing: %s", param_name);
+bool ErrorMissingProperty(chromeos::ErrorPtr* error, const char* param_name) {
+  chromeos::Error::AddToPrintf(error, errors::commands::kDomain,
+                               errors::commands::kPropertyMissing,
+                               "Required parameter missing: %s", param_name);
   return false;
 }
 }  // namespace
 
 // Specializations of TypedValueToJson<T>() for supported C++ types.
-std::unique_ptr<base::Value> TypedValueToJson(bool value, ErrorPtr* error) {
+std::unique_ptr<base::Value> TypedValueToJson(bool value,
+                                              chromeos::ErrorPtr* error) {
   return std::unique_ptr<base::Value>(base::Value::CreateBooleanValue(value));
 }
 
-std::unique_ptr<base::Value> TypedValueToJson(int value, ErrorPtr* error) {
+std::unique_ptr<base::Value> TypedValueToJson(int value,
+                                              chromeos::ErrorPtr* error) {
   return std::unique_ptr<base::Value>(base::Value::CreateIntegerValue(value));
 }
 
-std::unique_ptr<base::Value> TypedValueToJson(double value, ErrorPtr* error) {
+std::unique_ptr<base::Value> TypedValueToJson(double value,
+                                              chromeos::ErrorPtr* error) {
   return std::unique_ptr<base::Value>(base::Value::CreateDoubleValue(value));
 }
 
 std::unique_ptr<base::Value> TypedValueToJson(const std::string& value,
-                                              ErrorPtr* error) {
+                                              chromeos::ErrorPtr* error) {
   return std::unique_ptr<base::Value>(base::Value::CreateStringValue(value));
 }
 
 std::unique_ptr<base::Value> TypedValueToJson(const native_types::Object& value,
-                                              ErrorPtr* error) {
+                                              chromeos::ErrorPtr* error) {
   std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
   for (const auto& pair : value) {
     auto prop_value = pair.second->ToJson(error);
@@ -79,35 +83,36 @@
 
 bool TypedValueFromJson(const base::Value* value_in,
                         const ObjectSchema* object_schema,
-                        bool* value_out, ErrorPtr* error) {
+                        bool* value_out, chromeos::ErrorPtr* error) {
   return value_in->GetAsBoolean(value_out) ||
          ReportUnexpectedJson(value_in, value_out, error);
 }
 
 bool TypedValueFromJson(const base::Value* value_in,
                         const ObjectSchema* object_schema,
-                        int* value_out, ErrorPtr* error) {
+                        int* value_out, chromeos::ErrorPtr* error) {
   return value_in->GetAsInteger(value_out) ||
          ReportUnexpectedJson(value_in, value_out, error);
 }
 
 bool TypedValueFromJson(const base::Value* value_in,
                         const ObjectSchema* object_schema,
-                        double* value_out, ErrorPtr* error) {
+                        double* value_out, chromeos::ErrorPtr* error) {
   return value_in->GetAsDouble(value_out) ||
          ReportUnexpectedJson(value_in, value_out, error);
 }
 
 bool TypedValueFromJson(const base::Value* value_in,
                         const ObjectSchema* object_schema,
-                        std::string* value_out, ErrorPtr* error) {
+                        std::string* value_out, chromeos::ErrorPtr* error) {
   return value_in->GetAsString(value_out) ||
          ReportUnexpectedJson(value_in, value_out, error);
 }
 
 bool TypedValueFromJson(const base::Value* value_in,
                         const ObjectSchema* object_schema,
-                        native_types::Object* value_out, ErrorPtr* error) {
+                        native_types::Object* value_out,
+                        chromeos::ErrorPtr* error) {
   const base::DictionaryValue* dict = nullptr;
   if (!value_in->GetAsDictionary(&dict))
     return ReportUnexpectedJson(value_in, value_out, error);
@@ -142,9 +147,9 @@
     std::string key = iter.key();
     if (keys_processed.find(key) == keys_processed.end() &&
         !object_schema->GetExtraPropertiesAllowed()) {
-      Error::AddToPrintf(error, errors::commands::kDomain,
-                         errors::commands::kUnknownProperty,
-                         "Unrecognized parameter '%s'", key.c_str());
+      chromeos::Error::AddToPrintf(error, errors::commands::kDomain,
+                                   errors::commands::kUnknownProperty,
+                                   "Unrecognized parameter '%s'", key.c_str());
       return false;
     }
     iter.Advance();
@@ -155,10 +160,10 @@
     const PropType* prop_type = pair.second->GetPropType();
     CHECK(prop_type) << "Value property type must be available";
     if (!prop_type->ValidateConstraints(*pair.second, error)) {
-      Error::AddToPrintf(error, errors::commands::kDomain,
-                         errors::commands::kInvalidPropValue,
-                         "Invalid parameter value for property '%s'",
-                         pair.first.c_str());
+      chromeos::Error::AddToPrintf(error, errors::commands::kDomain,
+                                   errors::commands::kInvalidPropValue,
+                                   "Invalid parameter value for property '%s'",
+                                   pair.first.c_str());
       return false;
     }
   }
diff --git a/buffet/commands/schema_utils.h b/buffet/commands/schema_utils.h
index 0f89e27..16627af 100644
--- a/buffet/commands/schema_utils.h
+++ b/buffet/commands/schema_utils.h
@@ -13,8 +13,7 @@
 #include <vector>
 
 #include <base/values.h>
-
-#include <buffet/error.h>
+#include <chromeos/error.h>
 
 namespace buffet {
 
@@ -48,16 +47,19 @@
 // A bunch of helper function to create base::Value for specific C++ classes,
 // including vectors of types. These are used in template classes below
 // to simplify specialization logic.
-std::unique_ptr<base::Value> TypedValueToJson(bool value, ErrorPtr* error);
-std::unique_ptr<base::Value> TypedValueToJson(int value, ErrorPtr* error);
-std::unique_ptr<base::Value> TypedValueToJson(double value, ErrorPtr* error);
+std::unique_ptr<base::Value> TypedValueToJson(bool value,
+                                              chromeos::ErrorPtr* error);
+std::unique_ptr<base::Value> TypedValueToJson(int value,
+                                              chromeos::ErrorPtr* error);
+std::unique_ptr<base::Value> TypedValueToJson(double value,
+                                              chromeos::ErrorPtr* error);
 std::unique_ptr<base::Value> TypedValueToJson(const std::string& value,
-                                              ErrorPtr* error);
+                                              chromeos::ErrorPtr* error);
 std::unique_ptr<base::Value> TypedValueToJson(const native_types::Object& value,
-                                              ErrorPtr* error);
+                                              chromeos::ErrorPtr* error);
 template<typename T>
 std::unique_ptr<base::Value> TypedValueToJson(const std::vector<T>& values,
-                                              ErrorPtr* error) {
+                                              chromeos::ErrorPtr* error) {
   std::unique_ptr<base::ListValue> list(new base::ListValue);
   for (const auto& v : values) {
     auto json = TypedValueToJson(v, error);
@@ -73,19 +75,20 @@
 // Also used in template classes below to simplify specialization logic.
 bool TypedValueFromJson(const base::Value* value_in,
                         const ObjectSchema* object_schema,
-                        bool* value_out, ErrorPtr* error);
+                        bool* value_out, chromeos::ErrorPtr* error);
 bool TypedValueFromJson(const base::Value* value_in,
                         const ObjectSchema* object_schema,
-                        int* value_out, ErrorPtr* error);
+                        int* value_out, chromeos::ErrorPtr* error);
 bool TypedValueFromJson(const base::Value* value_in,
                         const ObjectSchema* object_schema,
-                        double* value_out, ErrorPtr* error);
+                        double* value_out, chromeos::ErrorPtr* error);
 bool TypedValueFromJson(const base::Value* value_in,
                         const ObjectSchema* object_schema,
-                        std::string* value_out, ErrorPtr* error);
+                        std::string* value_out, chromeos::ErrorPtr* error);
 bool TypedValueFromJson(const base::Value* value_in,
                         const ObjectSchema* object_schema,
-                        native_types::Object* value_out, ErrorPtr* error);
+                        native_types::Object* value_out,
+                        chromeos::ErrorPtr* error);
 
 bool operator==(const native_types::Object& obj1,
                 const native_types::Object& obj2);
diff --git a/buffet/commands/schema_utils_unittest.cc b/buffet/commands/schema_utils_unittest.cc
index e20532d..1a92d7f 100644
--- a/buffet/commands/schema_utils_unittest.cc
+++ b/buffet/commands/schema_utils_unittest.cc
@@ -73,7 +73,7 @@
                                          &value, nullptr));
   EXPECT_FALSE(value);
 
-  buffet::ErrorPtr error;
+  chromeos::ErrorPtr error;
   EXPECT_FALSE(buffet::TypedValueFromJson(CreateValue("0").get(), nullptr,
                                           &value, &error));
   EXPECT_EQ("type_mismatch", error->GetCode());
@@ -95,7 +95,7 @@
                                          &value, nullptr));
   EXPECT_EQ(-1234, value);
 
-  buffet::ErrorPtr error;
+  chromeos::ErrorPtr error;
   EXPECT_FALSE(buffet::TypedValueFromJson(CreateValue("'abc'").get(), nullptr,
                                           &value, &error));
   EXPECT_EQ("type_mismatch", error->GetCode());
@@ -123,7 +123,7 @@
                                          nullptr, &value, nullptr));
   EXPECT_EQ(-123.0, value);
 
-  buffet::ErrorPtr error;
+  chromeos::ErrorPtr error;
   EXPECT_FALSE(buffet::TypedValueFromJson(CreateValue("'abc'").get(), nullptr,
                                           &value, &error));
   EXPECT_EQ("type_mismatch", error->GetCode());
@@ -145,7 +145,7 @@
                                          &value, nullptr));
   EXPECT_EQ("abc", value);
 
-  buffet::ErrorPtr error;
+  chromeos::ErrorPtr error;
   EXPECT_FALSE(buffet::TypedValueFromJson(CreateValue("12").get(), nullptr,
                                           &value, &error));
   EXPECT_EQ("type_mismatch", error->GetCode());
@@ -172,7 +172,7 @@
                                name_prop->CreateValue(std::string("Bob"))));
   EXPECT_EQ(value2, value);
 
-  buffet::ErrorPtr error;
+  chromeos::ErrorPtr error;
   EXPECT_FALSE(buffet::TypedValueFromJson(CreateValue("'abc'").get(), nullptr,
                                           &value, &error));
   EXPECT_EQ("type_mismatch", error->GetCode());