OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 #ifndef SYNC_API_SYNC_ERROR_H_ | 5 #ifndef SYNC_API_SYNC_ERROR_H_ |
6 #define SYNC_API_SYNC_ERROR_H_ | 6 #define SYNC_API_SYNC_ERROR_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 UNRECOVERABLE_ERROR, // An unrecoverable runtime error was encountered, and | 31 UNRECOVERABLE_ERROR, // An unrecoverable runtime error was encountered, and |
32 // sync should be disabled and purged completely. | 32 // sync should be disabled and purged completely. |
33 DATATYPE_ERROR, // A datatype error was encountered, and the datatype | 33 DATATYPE_ERROR, // A datatype error was encountered, and the datatype |
34 // should be disabled and purged completely. Note that | 34 // should be disabled and purged completely. Note that |
35 // datatype errors may be reset, triggering a | 35 // datatype errors may be reset, triggering a |
36 // re-enable. | 36 // re-enable. |
37 PERSISTENCE_ERROR, // A persistence error was detected, and the | 37 PERSISTENCE_ERROR, // A persistence error was detected, and the |
38 // datataype should be associated after a sync update. | 38 // datataype should be associated after a sync update. |
39 CRYPTO_ERROR, // A cryptographer error was detected, and the | 39 CRYPTO_ERROR, // A cryptographer error was detected, and the |
40 // datatype should be associated after it is resolved. | 40 // datatype should be associated after it is resolved. |
41 UNREADY_ERROR, // The type is not ready to start yet, so should be | 41 UNREADY_ERROR, // A datatype is not ready to start yet, so should be |
42 // neither purged nor enabled until it is ready. | 42 // neither purged nor enabled until it is ready. |
| 43 DATATYPE_POLICY_ERROR // A datatype should be disabled and purged due |
| 44 // to configuration constraints. |
| 45 }; |
| 46 |
| 47 // Severity is used to indicate how an error should be logged and |
| 48 // represented to an end user. |
| 49 enum Severity { |
| 50 SYNC_ERROR_SEVERITY_ERROR, // Severe unrecoverable error. |
| 51 SYNC_ERROR_SEVERITY_INFO // Low-severity recoverable error or |
| 52 // configuration policy issue. |
43 }; | 53 }; |
44 | 54 |
45 // Default constructor refers to "no error", and IsSet() will return false. | 55 // Default constructor refers to "no error", and IsSet() will return false. |
46 SyncError(); | 56 SyncError(); |
47 | 57 |
48 // Create a new Sync error of type |error_type| triggered by |model_type| | 58 // Create a new Sync error of type |error_type| triggered by |model_type| |
49 // from the specified location. IsSet() will return true afterward. Will | 59 // from the specified location. IsSet() will return true afterward. Will |
50 // create and print an error specific message to LOG(ERROR). | 60 // create and print an error specific message to LOG(ERROR). |
51 SyncError(const tracked_objects::Location& location, | 61 SyncError(const tracked_objects::Location& location, |
52 ErrorType error_type, | 62 ErrorType error_type, |
(...skipping 16 matching lines...) Expand all Loading... |
69 | 79 |
70 // Whether this is a valid error or not. | 80 // Whether this is a valid error or not. |
71 bool IsSet() const; | 81 bool IsSet() const; |
72 | 82 |
73 // These must only be called if IsSet() is true. | 83 // These must only be called if IsSet() is true. |
74 const tracked_objects::Location& location() const; | 84 const tracked_objects::Location& location() const; |
75 const std::string& message() const; | 85 const std::string& message() const; |
76 ModelType model_type() const; | 86 ModelType model_type() const; |
77 ErrorType error_type() const; | 87 ErrorType error_type() const; |
78 | 88 |
| 89 // Error severity for logging and UI purposes. |
| 90 Severity GetSeverity() const; |
| 91 // Type specific message prefix for logging and UI purposes. |
| 92 std::string GetMessagePrefix() const; |
| 93 |
79 // Returns empty string is IsSet() is false. | 94 // Returns empty string is IsSet() is false. |
80 std::string ToString() const; | 95 std::string ToString() const; |
81 private: | 96 private: |
82 // Print error information to log. | 97 // Print error information to log. |
83 void PrintLogError() const; | 98 void PrintLogError() const; |
84 | 99 |
85 // Make a copy of a SyncError. If other.IsSet() == false, this->IsSet() will | 100 // Make a copy of a SyncError. If other.IsSet() == false, this->IsSet() will |
86 // now return false. | 101 // now return false. |
87 void Copy(const SyncError& other); | 102 void Copy(const SyncError& other); |
88 | 103 |
(...skipping 13 matching lines...) Expand all Loading... |
102 ModelType model_type_; | 117 ModelType model_type_; |
103 ErrorType error_type_; | 118 ErrorType error_type_; |
104 }; | 119 }; |
105 | 120 |
106 // gmock printer helper. | 121 // gmock printer helper. |
107 SYNC_EXPORT void PrintTo(const SyncError& sync_error, std::ostream* os); | 122 SYNC_EXPORT void PrintTo(const SyncError& sync_error, std::ostream* os); |
108 | 123 |
109 } // namespace syncer | 124 } // namespace syncer |
110 | 125 |
111 #endif // SYNC_API_SYNC_ERROR_H_ | 126 #endif // SYNC_API_SYNC_ERROR_H_ |
OLD | NEW |