| 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 #include "net/base/net_errors.h" | 5 #include "net/base/net_errors.h" |
| 6 #include "base/strings/string_number_conversions.h" |
| 6 | 7 |
| 7 namespace net { | 8 namespace net { |
| 8 | 9 |
| 9 const char kErrorDomain[] = "net"; | 10 const char kErrorDomain[] = "net"; |
| 10 | 11 |
| 11 std::string ErrorToString(int error) { | 12 std::string ErrorToString(int error) { |
| 12 return "net::" + ErrorToShortString(error); | 13 return "net::" + ErrorToShortString(error); |
| 13 } | 14 } |
| 14 | 15 |
| 15 std::string ErrorToShortString(int error) { | 16 std::string ErrorToShortString(int error) { |
| 16 if (error == 0) | 17 if (error == 0) |
| 17 return "OK"; | 18 return "OK"; |
| 18 | 19 |
| 19 const char* error_string; | 20 const char* error_string; |
| 20 switch (error) { | 21 switch (error) { |
| 21 #define NET_ERROR(label, value) \ | 22 #define NET_ERROR(label, value) \ |
| 22 case ERR_ ## label: \ | 23 case ERR_ ## label: \ |
| 23 error_string = # label; \ | 24 error_string = # label; \ |
| 24 break; | 25 break; |
| 25 #include "net/base/net_error_list.h" | 26 #include "net/base/net_error_list.h" |
| 26 #undef NET_ERROR | 27 #undef NET_ERROR |
| 27 default: | 28 default: |
| 28 NOTREACHED(); | 29 NOTREACHED(); |
| 29 error_string = "<unknown>"; | 30 error_string = "<unknown>"; |
| 30 } | 31 } |
| 31 return std::string("ERR_") + error_string; | 32 return std::string("ERR_") + error_string; |
| 32 } | 33 } |
| 33 | 34 |
| 35 std::string HttpErrorCodeToString(int error) { |
| 36 return std::string("HTTP_ERROR_") + base::IntToString(error); |
| 37 } |
| 38 |
| 34 bool IsCertificateError(int error) { | 39 bool IsCertificateError(int error) { |
| 35 // Certificate errors are negative integers from net::ERR_CERT_BEGIN | 40 // Certificate errors are negative integers from net::ERR_CERT_BEGIN |
| 36 // (inclusive) to net::ERR_CERT_END (exclusive) in *decreasing* order. | 41 // (inclusive) to net::ERR_CERT_END (exclusive) in *decreasing* order. |
| 37 // ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN is currently an exception to this | 42 // ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN is currently an exception to this |
| 38 // rule. | 43 // rule. |
| 39 return (error <= ERR_CERT_BEGIN && error > ERR_CERT_END) || | 44 return (error <= ERR_CERT_BEGIN && error > ERR_CERT_END) || |
| 40 (error == ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN); | 45 (error == ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN); |
| 41 } | 46 } |
| 42 | 47 |
| 43 bool IsClientCertificateError(int error) { | 48 bool IsClientCertificateError(int error) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 61 case base::File::FILE_ERROR_INVALID_URL: | 66 case base::File::FILE_ERROR_INVALID_URL: |
| 62 return ERR_INVALID_URL; | 67 return ERR_INVALID_URL; |
| 63 case base::File::FILE_ERROR_NOT_FOUND: | 68 case base::File::FILE_ERROR_NOT_FOUND: |
| 64 return ERR_FILE_NOT_FOUND; | 69 return ERR_FILE_NOT_FOUND; |
| 65 default: | 70 default: |
| 66 return ERR_FAILED; | 71 return ERR_FAILED; |
| 67 } | 72 } |
| 68 } | 73 } |
| 69 | 74 |
| 70 } // namespace net | 75 } // namespace net |
| OLD | NEW |