libchromeos: Add error location informaion to chromeos::Error

The error information logged always appears to come from error.cc
file in libchormeos since that's where LOG(ERROR) statement is.

Added the ability to pass in the actual source of the error by
using tracked_objects::Location parameter and "FROM_HERE" macros
used in base::TaskRunner-based classes.

While all the system log messages looked like this:

[ERROR:error.cc(15)] Domain=peerd, Code=service.info, Message=Invalid service key.

Now they appear as this:

ERROR:service.cc(155)] IsValidServiceInfo(...): Domain=peerd, Code=service.info, Message=Invalid service key.

We report the actual source file and line number where the error is
coming from, as well as the function name.

BUG=None
TEST=FEATURES=test emerge-link libchromeos buffet lorgnette peerd privetd

Change-Id: I647997c24d61a03f3b481e4c9ca336c90e99e9a3
Reviewed-on: https://chromium-review.googlesource.com/229071
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/buffet/commands/command_dictionary.cc b/buffet/commands/command_dictionary.cc
index 51ffb3d..98ffefc 100644
--- a/buffet/commands/command_dictionary.cc
+++ b/buffet/commands/command_dictionary.cc
@@ -36,7 +36,7 @@
     std::string package_name = package_iter.key();
     const base::DictionaryValue* package_value = nullptr;
     if (!package_iter.value().GetAsDictionary(&package_value)) {
-      chromeos::Error::AddToPrintf(error, errors::commands::kDomain,
+      chromeos::Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
                                    errors::commands::kTypeMismatch,
                                    "Expecting an object for package '%s'",
                                    package_name.c_str());
@@ -48,7 +48,7 @@
       std::string command_name = command_iter.key();
       if (command_name.empty()) {
         chromeos::Error::AddToPrintf(
-            error, errors::commands::kDomain,
+            error, FROM_HERE, errors::commands::kDomain,
             errors::commands::kInvalidCommandName,
             "Unnamed command encountered in package '%s'",
             package_name.c_str());
@@ -56,7 +56,8 @@
       }
       const base::DictionaryValue* command_value = nullptr;
       if (!command_iter.value().GetAsDictionary(&command_value)) {
-        chromeos::Error::AddToPrintf(error, errors::commands::kDomain,
+        chromeos::Error::AddToPrintf(error, FROM_HERE,
+                                     errors::commands::kDomain,
                                      errors::commands::kTypeMismatch,
                                      "Expecting an object for command '%s'",
                                      command_name.c_str());
@@ -71,7 +72,7 @@
       if (!command_value->GetDictionaryWithoutPathExpansion(
           commands::attributes::kCommand_Parameters, &command_schema_def)) {
         chromeos::Error::AddToPrintf(
-            error, errors::commands::kDomain,
+            error, FROM_HERE, errors::commands::kDomain,
             errors::commands::kPropertyMissing,
             "Command definition '%s' is missing property '%s'",
             full_command_name.c_str(),
@@ -93,7 +94,7 @@
         if (!base_def) {
           if (command_name.front() != '_') {
             chromeos::Error::AddToPrintf(
-                error, errors::commands::kDomain,
+                error, FROM_HERE, errors::commands::kDomain,
                 errors::commands::kInvalidCommandName,
                 "The name of custom command '%s' in package '%s'"
                 " must start with '_'",
@@ -105,7 +106,8 @@
 
       auto command_schema = std::make_shared<ObjectSchema>();
       if (!command_schema->FromJson(command_schema_def, base_def, error)) {
-        chromeos::Error::AddToPrintf(error, errors::commands::kDomain,
+        chromeos::Error::AddToPrintf(error, FROM_HERE,
+                                     errors::commands::kDomain,
                                      errors::commands::kInvalidObjectSchema,
                                      "Invalid definition for command '%s'",
                                      full_command_name.c_str());
@@ -128,7 +130,7 @@
     auto iter = definitions_.find(pair.first);
     if (iter != definitions_.end()) {
         chromeos::Error::AddToPrintf(
-            error, errors::commands::kDomain,
+            error, FROM_HERE, errors::commands::kDomain,
             errors::commands::kDuplicateCommandDef,
             "Definition for command '%s' overrides an earlier "
             "definition in category '%s'",