OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 #include "google_apis/drive/drive_api_error_codes.h" | 5 #include "google_apis/drive/drive_api_error_codes.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 | 9 |
10 namespace google_apis { | 10 namespace google_apis { |
11 | 11 |
12 std::string DriveApiErrorCodeToString(DriveApiErrorCode error) { | 12 std::string DriveApiErrorCodeToString(DriveApiErrorCode error) { |
13 switch (error) { | 13 switch (error) { |
14 case HTTP_SUCCESS: | 14 case HTTP_SUCCESS: |
15 return"HTTP_SUCCESS"; | 15 return "HTTP_SUCCESS"; |
16 | 16 |
17 case HTTP_CREATED: | 17 case HTTP_CREATED: |
18 return"HTTP_CREATED"; | 18 return "HTTP_CREATED"; |
19 | 19 |
20 case HTTP_NO_CONTENT: | 20 case HTTP_NO_CONTENT: |
21 return"HTTP_NO_CONTENT"; | 21 return "HTTP_NO_CONTENT"; |
22 | 22 |
23 case HTTP_FOUND: | 23 case HTTP_FOUND: |
24 return"HTTP_FOUND"; | 24 return "HTTP_FOUND"; |
25 | 25 |
26 case HTTP_NOT_MODIFIED: | 26 case HTTP_NOT_MODIFIED: |
27 return"HTTP_NOT_MODIFIED"; | 27 return "HTTP_NOT_MODIFIED"; |
28 | 28 |
29 case HTTP_RESUME_INCOMPLETE: | 29 case HTTP_RESUME_INCOMPLETE: |
30 return"HTTP_RESUME_INCOMPLETE"; | 30 return "HTTP_RESUME_INCOMPLETE"; |
31 | 31 |
32 case HTTP_BAD_REQUEST: | 32 case HTTP_BAD_REQUEST: |
33 return"HTTP_BAD_REQUEST"; | 33 return "HTTP_BAD_REQUEST"; |
34 | 34 |
35 case HTTP_UNAUTHORIZED: | 35 case HTTP_UNAUTHORIZED: |
36 return"HTTP_UNAUTHORIZED"; | 36 return "HTTP_UNAUTHORIZED"; |
37 | 37 |
38 case HTTP_FORBIDDEN: | 38 case HTTP_FORBIDDEN: |
39 return"HTTP_FORBIDDEN"; | 39 return "HTTP_FORBIDDEN"; |
40 | 40 |
41 case HTTP_NOT_FOUND: | 41 case HTTP_NOT_FOUND: |
42 return"HTTP_NOT_FOUND"; | 42 return "HTTP_NOT_FOUND"; |
43 | 43 |
44 case HTTP_CONFLICT: | 44 case HTTP_CONFLICT: |
45 return"HTTP_CONFLICT"; | 45 return "HTTP_CONFLICT"; |
46 | 46 |
47 case HTTP_GONE: | 47 case HTTP_GONE: |
48 return "HTTP_GONE"; | 48 return "HTTP_GONE"; |
49 | 49 |
50 case HTTP_LENGTH_REQUIRED: | 50 case HTTP_LENGTH_REQUIRED: |
51 return"HTTP_LENGTH_REQUIRED"; | 51 return "HTTP_LENGTH_REQUIRED"; |
52 | 52 |
53 case HTTP_PRECONDITION: | 53 case HTTP_PRECONDITION: |
54 return"HTTP_PRECONDITION"; | 54 return "HTTP_PRECONDITION"; |
55 | 55 |
56 case HTTP_INTERNAL_SERVER_ERROR: | 56 case HTTP_INTERNAL_SERVER_ERROR: |
57 return"HTTP_INTERNAL_SERVER_ERROR"; | 57 return "HTTP_INTERNAL_SERVER_ERROR"; |
58 | 58 |
59 case HTTP_NOT_IMPLEMENTED: | 59 case HTTP_NOT_IMPLEMENTED: |
60 return "HTTP_NOT_IMPLEMENTED"; | 60 return "HTTP_NOT_IMPLEMENTED"; |
61 | 61 |
62 case HTTP_BAD_GATEWAY: | 62 case HTTP_BAD_GATEWAY: |
63 return"HTTP_BAD_GATEWAY"; | 63 return "HTTP_BAD_GATEWAY"; |
64 | 64 |
65 case HTTP_SERVICE_UNAVAILABLE: | 65 case HTTP_SERVICE_UNAVAILABLE: |
66 return"HTTP_SERVICE_UNAVAILABLE"; | 66 return "HTTP_SERVICE_UNAVAILABLE"; |
67 | 67 |
68 case DRIVE_PARSE_ERROR: | 68 case DRIVE_PARSE_ERROR: |
69 return"DRIVE_PARSE_ERROR"; | 69 return "DRIVE_PARSE_ERROR"; |
70 | 70 |
71 case DRIVE_FILE_ERROR: | 71 case DRIVE_FILE_ERROR: |
72 return"DRIVE_FILE_ERROR"; | 72 return "DRIVE_FILE_ERROR"; |
73 | 73 |
74 case DRIVE_CANCELLED: | 74 case DRIVE_CANCELLED: |
75 return"DRIVE_CANCELLED"; | 75 return "DRIVE_CANCELLED"; |
76 | 76 |
77 case DRIVE_OTHER_ERROR: | 77 case DRIVE_OTHER_ERROR: |
78 return"DRIVE_OTHER_ERROR"; | 78 return "DRIVE_OTHER_ERROR"; |
79 | 79 |
80 case DRIVE_NO_CONNECTION: | 80 case DRIVE_NO_CONNECTION: |
81 return"DRIVE_NO_CONNECTION"; | 81 return "DRIVE_NO_CONNECTION"; |
82 | 82 |
83 case DRIVE_NOT_READY: | 83 case DRIVE_NOT_READY: |
84 return"DRIVE_NOT_READY"; | 84 return "DRIVE_NOT_READY"; |
85 | 85 |
86 case DRIVE_NO_SPACE: | 86 case DRIVE_NO_SPACE: |
87 return"DRIVE_NO_SPACE"; | 87 return "DRIVE_NO_SPACE"; |
| 88 |
| 89 case DRIVE_RESPONSE_TOO_LARGE: |
| 90 return "DRIVE_RESPONSE_TOO_LARGE"; |
88 } | 91 } |
89 | 92 |
90 return "UNKNOWN_ERROR_" + base::IntToString(error); | 93 return "UNKNOWN_ERROR_" + base::IntToString(error); |
91 } | 94 } |
92 | 95 |
93 bool IsSuccessfulDriveApiErrorCode(DriveApiErrorCode error) { | 96 bool IsSuccessfulDriveApiErrorCode(DriveApiErrorCode error) { |
94 return 200 <= error && error <= 299; | 97 return 200 <= error && error <= 299; |
95 } | 98 } |
96 | 99 |
97 } // namespace google_apis | 100 } // namespace google_apis |
OLD | NEW |