1 // Copyright 2013 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 "google_apis/drive/drive_api_error_codes.h"
7 #include "base/logging.h"
8 #include "base/strings/string_number_conversions.h"
10 namespace google_apis
{
12 std::string
DriveApiErrorCodeToString(DriveApiErrorCode error
) {
15 return "HTTP_SUCCESS";
18 return "HTTP_CREATED";
21 return "HTTP_NO_CONTENT";
26 case HTTP_NOT_MODIFIED
:
27 return "HTTP_NOT_MODIFIED";
29 case HTTP_RESUME_INCOMPLETE
:
30 return "HTTP_RESUME_INCOMPLETE";
32 case HTTP_BAD_REQUEST
:
33 return "HTTP_BAD_REQUEST";
35 case HTTP_UNAUTHORIZED
:
36 return "HTTP_UNAUTHORIZED";
39 return "HTTP_FORBIDDEN";
42 return "HTTP_NOT_FOUND";
45 return "HTTP_CONFLICT";
50 case HTTP_LENGTH_REQUIRED
:
51 return "HTTP_LENGTH_REQUIRED";
53 case HTTP_PRECONDITION
:
54 return "HTTP_PRECONDITION";
56 case HTTP_INTERNAL_SERVER_ERROR
:
57 return "HTTP_INTERNAL_SERVER_ERROR";
59 case HTTP_NOT_IMPLEMENTED
:
60 return "HTTP_NOT_IMPLEMENTED";
62 case HTTP_BAD_GATEWAY
:
63 return "HTTP_BAD_GATEWAY";
65 case HTTP_SERVICE_UNAVAILABLE
:
66 return "HTTP_SERVICE_UNAVAILABLE";
68 case DRIVE_PARSE_ERROR
:
69 return "DRIVE_PARSE_ERROR";
71 case DRIVE_FILE_ERROR
:
72 return "DRIVE_FILE_ERROR";
75 return "DRIVE_CANCELLED";
77 case DRIVE_OTHER_ERROR
:
78 return "DRIVE_OTHER_ERROR";
80 case DRIVE_NO_CONNECTION
:
81 return "DRIVE_NO_CONNECTION";
84 return "DRIVE_NOT_READY";
87 return "DRIVE_NO_SPACE";
89 case DRIVE_RESPONSE_TOO_LARGE
:
90 return "DRIVE_RESPONSE_TOO_LARGE";
93 return "UNKNOWN_ERROR_" + base::IntToString(error
);
96 bool IsSuccessfulDriveApiErrorCode(DriveApiErrorCode error
) {
97 return 200 <= error
&& error
<= 299;
100 } // namespace google_apis