1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "sync/api/sync_error.h"
9 #include "base/location.h"
10 #include "base/logging.h"
11 #include "sync/internal_api/public/base/model_type.h"
15 SyncError::SyncError() {
19 SyncError::SyncError(const tracked_objects::Location
& location
,
20 const std::string
& message
,
22 Init(location
, message
, type
);
26 SyncError::SyncError(const SyncError
& other
) {
30 SyncError::~SyncError() {
33 SyncError
& SyncError::operator=(const SyncError
& other
) {
41 void SyncError::Copy(const SyncError
& other
) {
43 Init(other
.location(),
51 void SyncError::Clear() {
53 message_
= std::string();
57 void SyncError::Reset(const tracked_objects::Location
& location
,
58 const std::string
& message
,
60 Init(location
, message
, type
);
64 void SyncError::Init(const tracked_objects::Location
& location
,
65 const std::string
& message
,
67 location_
.reset(new tracked_objects::Location(location
));
72 bool SyncError::IsSet() const {
73 return location_
.get() != NULL
;
77 const tracked_objects::Location
& SyncError::location() const {
82 const std::string
& SyncError::message() const {
87 ModelType
SyncError::type() const {
92 std::string
SyncError::ToString() const {
96 return location_
->ToString() + ", " + ModelTypeToString(type_
) +
97 ", Sync Error: " + message_
;
100 void SyncError::PrintLogError() const {
101 LAZY_STREAM(logging::LogMessage(location_
->file_name(),
102 location_
->line_number(),
103 logging::LOG_ERROR
).stream(),
105 << ModelTypeToString(type_
) << ", Sync Error: " << message_
;
108 void PrintTo(const SyncError
& sync_error
, std::ostream
* os
) {
109 *os
<< sync_error
.ToString();
112 } // namespace syncer