Chromium Code Reviews| Index: sync/api/sync_error.cc |
| diff --git a/sync/api/sync_error.cc b/sync/api/sync_error.cc |
| index 1100a11028d2cfe83d3edeb05f0cb93dcfdb29bb..bcf3b8916a3e2feb7aba911ef62602885327c7dc 100644 |
| --- a/sync/api/sync_error.cc |
| +++ b/sync/api/sync_error.cc |
| @@ -18,30 +18,10 @@ SyncError::SyncError() { |
| SyncError::SyncError(const tracked_objects::Location& location, |
| ErrorType error_type, |
| - const std::string& custom_message, |
| + const std::string& message, |
| ModelType model_type) { |
| - std::string type_message; |
| - switch (error_type) { |
| - case UNRECOVERABLE_ERROR: |
| - type_message = "unrecoverable error was encountered: "; |
| - break; |
| - case DATATYPE_ERROR: |
| - type_message = "datatype error was encountered: "; |
| - break; |
| - case PERSISTENCE_ERROR: |
| - type_message = "persistence error was encountered: "; |
| - break; |
| - case CRYPTO_ERROR: |
| - type_message = "cryptographer error was encountered: "; |
| - break; |
| - case UNREADY_ERROR: |
| - type_message = "unready error was encountered: "; |
| - break; |
| - case UNSET: |
| - NOTREACHED() << "Invalid error type"; |
| - return; |
| - } |
| - Init(location, type_message + custom_message, model_type, error_type); |
| + CHECK(error_type != UNSET); |
|
Nicolas Zea
2014/07/14 17:36:02
nit: prefer DCHECK vs CHECK, unless it's a securit
stanisc
2014/07/15 16:10:01
Done.
|
| + Init(location, message, model_type, error_type); |
| PrintLogError(); |
| } |
| @@ -120,20 +100,59 @@ SyncError::ErrorType SyncError::error_type() const { |
| return error_type_; |
| } |
| +logging::LogSeverity SyncError::severity() const { |
|
Nicolas Zea
2014/07/14 17:36:02
nit: accessors should do nothing more than access
stanisc
2014/07/15 16:10:01
Done.
|
| + switch (error_type_) { |
| + case UNREADY_ERROR: |
| + case DATATYPE_POLICY_ERROR: |
| + return logging::LOG_INFO; |
| + default: |
| + return logging::LOG_ERROR; |
| + } |
| +} |
| + |
| +std::string SyncError::type_message_prefix() const { |
| + std::string type_message; |
| + switch (error_type_) { |
| + case UNRECOVERABLE_ERROR: |
| + type_message = "unrecoverable error was encountered: "; |
| + break; |
| + case DATATYPE_ERROR: |
| + type_message = "datatype error was encountered: "; |
| + break; |
| + case PERSISTENCE_ERROR: |
| + type_message = "persistence error was encountered: "; |
| + break; |
| + case CRYPTO_ERROR: |
| + type_message = "cryptographer error was encountered: "; |
| + break; |
| + case UNREADY_ERROR: |
| + type_message = "unready error was encountered: "; |
| + break; |
| + case DATATYPE_POLICY_ERROR: |
| + type_message = "disabled due to configuration constraints: "; |
| + break; |
| + case UNSET: |
| + NOTREACHED() << "Invalid error type"; |
| + break; |
| + } |
| + return type_message; |
| +} |
| + |
| std::string SyncError::ToString() const { |
| if (!IsSet()) { |
| return std::string(); |
| } |
| return location_->ToString() + ", " + ModelTypeToString(model_type_) + |
| - " " + message_; |
| + " " + type_message_prefix() + message_; |
| } |
| void SyncError::PrintLogError() const { |
| LAZY_STREAM(logging::LogMessage(location_->file_name(), |
| location_->line_number(), |
| - logging::LOG_ERROR).stream(), |
| - LOG_IS_ON(ERROR)) |
| - << ModelTypeToString(model_type_) << " " << message_; |
| + severity()).stream(), |
| + severity() >= ::logging::GetMinLogLevel()) |
| + << ModelTypeToString(model_type_) << " " |
| + << type_message_prefix() << message_; |
| } |
| void PrintTo(const SyncError& sync_error, std::ostream* os) { |