shill; Create Error::LogMessage utility routine

This combines a LOG(ERROR) with an error->Populate().  It has
the downside of having the error originate from error.cc, as
opposed to the orignal call site of the error, so readers of
the log need to rely on the content of the error message to
tell where the error came from.

BUG=chromium-os:22426
TEST=Rerun unit tests, look at all error messages

Change-Id: I9ccd5385db7c4eda34eb242abd02c57c899d161c
Reviewed-on: https://gerrit.chromium.org/gerrit/11098
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/device.cc b/device.cc
index cbc98ad..90f6eb1 100644
--- a/device.cc
+++ b/device.cc
@@ -148,50 +148,38 @@
 
 void Device::Scan(Error *error) {
   VLOG(2) << "Device " << link_name_ << " scan requested.";
-  const string kMessage = "Device doesn't support scan.";
-  LOG(ERROR) << kMessage;
-  CHECK(error);
-  error->Populate(Error::kNotSupported, kMessage);
+  Error::PopulateAndLog(error, Error::kNotSupported,
+                        "Device doesn't support scan.");
 }
 
 void Device::RegisterOnNetwork(const std::string &/*network_id*/,
                                Error *error) {
-  const string kMessage = "Device doesn't support network registration.";
-  LOG(ERROR) << kMessage;
-  CHECK(error);
-  error->Populate(Error::kNotSupported, kMessage);
+  Error::PopulateAndLog(error, Error::kNotSupported,
+                        "Device doesn't support network registration.");
 }
 
 void Device::RequirePIN(const string &/*pin*/, bool /*require*/, Error *error) {
-  const string kMessage = "Device doesn't support RequirePIN.";
-  LOG(ERROR) << kMessage;
-  CHECK(error);
-  error->Populate(Error::kNotSupported, kMessage);
+  Error::PopulateAndLog(error, Error::kNotSupported,
+                        "Device doesn't support RequirePIN.");
 }
 
 void Device::EnterPIN(const string &/*pin*/, Error *error) {
-  const string kMessage = "Device doesn't support EnterPIN.";
-  LOG(ERROR) << kMessage;
-  CHECK(error);
-  error->Populate(Error::kNotSupported, kMessage);
+  Error::PopulateAndLog(error, Error::kNotSupported,
+                        "Device doesn't support EnterPIN.");
 }
 
 void Device::UnblockPIN(const string &/*unblock_code*/,
                         const string &/*pin*/,
                         Error *error) {
-  const string kMessage = "Device doesn't support UnblockPIN.";
-  LOG(ERROR) << kMessage;
-  CHECK(error);
-  error->Populate(Error::kNotSupported, kMessage);
+  Error::PopulateAndLog(error, Error::kNotSupported,
+                        "Device doesn't support UnblockPIN.");
 }
 
 void Device::ChangePIN(const string &/*old_pin*/,
                        const string &/*new_pin*/,
                        Error *error) {
-  const string kMessage = "Device doesn't support ChangePIN.";
-  LOG(ERROR) << kMessage;
-  CHECK(error);
-  error->Populate(Error::kNotSupported, kMessage);
+  Error::PopulateAndLog(error, Error::kNotSupported,
+                        "Device doesn't support ChangePIN.");
 }
 
 string Device::GetRpcIdentifier() {