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