| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_INTERNAL_API_PUBLIC_UTIL_SYNCER_ERROR_H_ | 5 #ifndef SYNC_INTERNAL_API_PUBLIC_UTIL_SYNCER_ERROR_H_ |
| 6 #define SYNC_INTERNAL_API_PUBLIC_UTIL_SYNCER_ERROR_H_ | 6 #define SYNC_INTERNAL_API_PUBLIC_UTIL_SYNCER_ERROR_H_ |
| 7 | 7 |
| 8 namespace syncer { | 8 namespace syncer { |
| 9 | 9 |
| 10 // This enum describes all the ways a SyncerCommand can fail. | 10 // This enum describes all the ways a SyncerCommand can fail. |
| 11 // | 11 // |
| 12 // SyncerCommands do many different things, but they share a common function | 12 // SyncerCommands do many different things, but they share a common function |
| 13 // signature. This enum, the return value for all SyncerCommands, must be able | 13 // signature. This enum, the return value for all SyncerCommands, must be able |
| 14 // to describe any possible failure for all SyncerComand. | 14 // to describe any possible failure for all SyncerComand. |
| 15 // | 15 // |
| 16 // For convenience, functions which are invoked only by SyncerCommands may also | 16 // For convenience, functions which are invoked only by SyncerCommands may also |
| 17 // return a SyncerError. It saves us having to write a conversion function, and | 17 // return a SyncerError. It saves us having to write a conversion function, and |
| 18 // it makes refactoring easier. | 18 // it makes refactoring easier. |
| 19 enum SyncerError { | 19 enum SyncerError { |
| 20 UNSET = 0, // Default value. | 20 UNSET = 0, // Default value. |
| 21 DIRECTORY_LOOKUP_FAILED, // Local directory lookup failure. | 21 DIRECTORY_LOOKUP_FAILED, // Local directory lookup failure. |
| 22 | 22 |
| 23 NETWORK_CONNECTION_UNAVAILABLE, // Connectivity failure. | 23 NETWORK_CONNECTION_UNAVAILABLE, // Connectivity failure. |
| 24 NETWORK_IO_ERROR, // Response buffer read error. | 24 NETWORK_IO_ERROR, // Response buffer read error. |
| 25 SYNC_SERVER_ERROR, // Non auth HTTP error. | 25 SYNC_SERVER_ERROR, // Non auth HTTP error. |
| 26 SYNC_AUTH_ERROR, // HTTP auth error. | 26 SYNC_AUTH_ERROR, // HTTP auth error. |
| 27 | 27 |
| 28 // Based on values returned by server. Most are defined in sync.proto. | 28 // Based on values returned by server. Most are defined in sync.proto. |
| 29 SERVER_RETURN_INVALID_CREDENTIAL, | 29 SERVER_RETURN_INVALID_CREDENTIAL, |
| 30 FIRST_SERVER_RETURN_VALUE = SERVER_RETURN_INVALID_CREDENTIAL, |
| 31 |
| 30 SERVER_RETURN_UNKNOWN_ERROR, | 32 SERVER_RETURN_UNKNOWN_ERROR, |
| 31 SERVER_RETURN_THROTTLED, | 33 SERVER_RETURN_THROTTLED, |
| 32 SERVER_RETURN_TRANSIENT_ERROR, | 34 SERVER_RETURN_TRANSIENT_ERROR, |
| 33 SERVER_RETURN_MIGRATION_DONE, | 35 SERVER_RETURN_MIGRATION_DONE, |
| 34 SERVER_RETURN_CLEAR_PENDING, | 36 SERVER_RETURN_CLEAR_PENDING, |
| 35 SERVER_RETURN_NOT_MY_BIRTHDAY, | 37 SERVER_RETURN_NOT_MY_BIRTHDAY, |
| 36 SERVER_RESPONSE_VALIDATION_FAILED, | 38 SERVER_RESPONSE_VALIDATION_FAILED, |
| 37 | 39 |
| 38 SYNCER_OK | 40 SYNCER_OK |
| 39 }; | 41 }; |
| 40 | 42 |
| 41 const char * GetSyncerErrorString(SyncerError); | 43 const char * GetSyncerErrorString(SyncerError); |
| 42 | 44 |
| 43 // Helper to check that |error| is set to something (not UNSET) and is not | 45 // Helper to check that |error| is set to something (not UNSET) and is not |
| 44 // SYNCER_OK. | 46 // SYNCER_OK. |
| 45 bool SyncerErrorIsError(SyncerError error); | 47 bool SyncerErrorIsError(SyncerError error); |
| 46 | 48 |
| 47 } // namespace syncer | 49 } // namespace syncer |
| 48 | 50 |
| 49 #endif // SYNC_INTERNAL_API_PUBLIC_UTIL_SYNCER_ERROR_H_ | 51 #endif // SYNC_INTERNAL_API_PUBLIC_UTIL_SYNCER_ERROR_H_ |
| OLD | NEW |