Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/sync/api/sync_error.h" | 5 #include "chrome/browser/sync/api/sync_error.h" |
| 6 | 6 |
| 7 #include <ostream> | |
| 8 | |
| 7 #include "base/logging.h" | 9 #include "base/logging.h" |
| 8 #include "base/tracked.h" | 10 #include "base/tracked.h" |
| 11 #include "chrome/browser/sync/syncable/model_type.h" | |
| 9 | 12 |
| 10 SyncError::SyncError() { | 13 SyncError::SyncError() { |
| 11 Clear(); | 14 Clear(); |
| 12 } | 15 } |
| 13 | 16 |
| 14 SyncError::SyncError(const tracked_objects::Location& location, | 17 SyncError::SyncError(const tracked_objects::Location& location, |
| 15 const std::string& message, | 18 const std::string& message, |
| 16 syncable::ModelType type) { | 19 syncable::ModelType type) { |
| 17 Init(location, message, type); | 20 Init(location, message, type); |
| 18 PrintLogError(); | 21 PrintLogError(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 const std::string& SyncError::message() const { | 79 const std::string& SyncError::message() const { |
| 77 CHECK(IsSet()); | 80 CHECK(IsSet()); |
| 78 return message_; | 81 return message_; |
| 79 } | 82 } |
| 80 | 83 |
| 81 syncable::ModelType SyncError::type() const { | 84 syncable::ModelType SyncError::type() const { |
| 82 CHECK(IsSet()); | 85 CHECK(IsSet()); |
| 83 return type_; | 86 return type_; |
| 84 } | 87 } |
| 85 | 88 |
| 89 std::string SyncError::ToString() const { | |
| 90 if (IsSet()) { | |
| 91 return "{" + location_->ToString() + ", " + ", " + | |
|
akalin
2011/09/22 02:59:44
return "{ location: " + ... + ", type: " + ... ",
James Hawkins
2011/09/22 21:01:58
Done.
| |
| 92 syncable::ModelTypeToString(type()) + ", " + message() + "}"; | |
| 93 } | |
| 94 | |
| 95 return "<Unset SyncError>"; | |
| 96 } | |
| 97 | |
| 86 void SyncError::PrintLogError() const { | 98 void SyncError::PrintLogError() const { |
| 87 LAZY_STREAM(logging::LogMessage(location_->file_name(), | 99 LAZY_STREAM(logging::LogMessage(location_->file_name(), |
| 88 location_->line_number(), | 100 location_->line_number(), |
| 89 logging::LOG_ERROR).stream(), | 101 logging::LOG_ERROR).stream(), |
| 90 LOG_IS_ON(ERROR)) | 102 LOG_IS_ON(ERROR)) |
| 91 << syncable::ModelTypeToString(type_) << " Sync Error: " << message_; | 103 << syncable::ModelTypeToString(type_) << " Sync Error: " << message_; |
| 92 } | 104 } |
| 105 | |
| 106 void PrintTo(const SyncError& sync_error, std::ostream* os) { | |
| 107 *os << sync_error.ToString(); | |
| 108 } | |
| OLD | NEW |