[email protected] | ed2e766d | 2012-07-25 00:10:51 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 4 | |
5 | #ifndef NET_BASE_NET_ERRORS_H__ | ||||
6 | #define NET_BASE_NET_ERRORS_H__ | ||||
7 | |||||
[email protected] | 3030374e3 | 2014-08-07 16:12:06 | [diff] [blame] | 8 | #include <string> |
[email protected] | 961fefb | 2011-05-24 13:59:58 | [diff] [blame] | 9 | #include <vector> |
10 | |||||
[email protected] | 141bcc5 | 2014-01-27 21:36:00 | [diff] [blame] | 11 | #include "base/files/file.h" |
pkasting | 32c74152 | 2014-11-26 01:03:56 | [diff] [blame] | 12 | #include "base/logging.h" |
[email protected] | 172da1b | 2011-08-12 15:52:26 | [diff] [blame] | 13 | #include "net/base/net_export.h" |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 14 | |
15 | namespace net { | ||||
16 | |||||
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 17 | // Error values are negative. |
[email protected] | e7b055b | 2008-08-06 03:09:14 | [diff] [blame] | 18 | enum Error { |
Marcin WiÄ…cek | 1a85c30 | 2019-05-01 21:41:41 | [diff] [blame] | 19 | // No error. Change NetError.template after changing value. |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 20 | OK = 0, |
21 | |||||
22 | #define NET_ERROR(label, value) ERR_ ## label = value, | ||||
23 | #include "net/base/net_error_list.h" | ||||
24 | #undef NET_ERROR | ||||
25 | |||||
26 | // The value of the first certificate error code. | ||||
27 | ERR_CERT_BEGIN = ERR_CERT_COMMON_NAME_INVALID, | ||||
28 | }; | ||||
29 | |||||
30 | // Returns a textual representation of the error code for logging purposes. | ||||
[email protected] | 3030374e3 | 2014-08-07 16:12:06 | [diff] [blame] | 31 | NET_EXPORT std::string ErrorToString(int error); |
32 | |||||
33 | // Same as above, but leaves off the leading "net::". | ||||
34 | NET_EXPORT std::string ErrorToShortString(int error); | ||||
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 35 | |
Brad Lassey | 16c13f7 | 2018-03-19 19:37:50 | [diff] [blame] | 36 | // Returns a textual representation of the error code and the extended eror |
37 | // code. | ||||
38 | NET_EXPORT std::string ExtendedErrorToString(int error, | ||||
39 | int extended_error_code); | ||||
40 | |||||
Eric Roman | e28b6027 | 2019-10-09 19:22:17 | [diff] [blame] | 41 | // Returns true if |error| is a certificate error code. Note this does not |
42 | // include errors for client certificates. | ||||
[email protected] | 3030374e3 | 2014-08-07 16:12:06 | [diff] [blame] | 43 | NET_EXPORT bool IsCertificateError(int error); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 44 | |
davidben | 3a92a96b | 2014-11-07 23:18:05 | [diff] [blame] | 45 | // Returns true if |error| is a client certificate authentication error. This |
46 | // does not include ERR_SSL_PROTOCOL_ERROR which may also signal a bad client | ||||
47 | // certificate. | ||||
48 | NET_EXPORT bool IsClientCertificateError(int error); | ||||
49 | |||||
dalyk | da475cee | 2020-01-17 23:45:36 | [diff] [blame] | 50 | // Returns true if |error| is an error from hostname resolution. |
51 | NET_EXPORT bool IsHostnameResolutionError(int error); | ||||
tfarina | 995fb18 | 2016-10-05 21:03:44 | [diff] [blame] | 52 | |
Antonio Sartori | d8ec881 | 2020-06-16 12:47:24 | [diff] [blame^] | 53 | // Returns true if |error| means that the request has been blocked. |
54 | NET_EXPORT bool IsRequestBlockedError(int error); | ||||
55 | |||||
[email protected] | 051e4ec | 2011-03-15 20:46:32 | [diff] [blame] | 56 | // Map system error code to Error. |
pkasting | 32c74152 | 2014-11-26 01:03:56 | [diff] [blame] | 57 | NET_EXPORT Error MapSystemError(logging::SystemErrorCode os_error); |
[email protected] | 051e4ec | 2011-03-15 20:46:32 | [diff] [blame] | 58 | |
[email protected] | 141bcc5 | 2014-01-27 21:36:00 | [diff] [blame] | 59 | // A convenient function to translate file error to net error code. |
60 | NET_EXPORT Error FileErrorToNetError(base::File::Error file_error); | ||||
[email protected] | ed2e766d | 2012-07-25 00:10:51 | [diff] [blame] | 61 | |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 62 | } // namespace net |
63 | |||||
64 | #endif // NET_BASE_NET_ERRORS_H__ |