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