xref: /aosp_15_r20/external/cronet/net/base/net_errors.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2012 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef NET_BASE_NET_ERRORS_H__
6 #define NET_BASE_NET_ERRORS_H__
7 
8 #include <string>
9 
10 #include "base/files/file.h"
11 #include "base/logging.h"
12 #include "net/base/net_export.h"
13 
14 namespace net {
15 
16 // Error values are negative.
17 enum Error {
18   // No error. Change NetError.template after changing value.
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.
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);
34 
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 
40 // Returns true if |error| is a certificate error code. Note this does not
41 // include errors for client certificates.
42 NET_EXPORT bool IsCertificateError(int error);
43 
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 
49 // Returns true if |error| is an error from hostname resolution.
50 NET_EXPORT bool IsHostnameResolutionError(int error);
51 
52 // Returns true if |error| means that the request has been blocked.
53 NET_EXPORT bool IsRequestBlockedError(int error);
54 
55 // Map system error code to Error.
56 NET_EXPORT Error MapSystemError(logging::SystemErrorCode os_error);
57 
58 // A convenient function to translate file error to net error code.
59 NET_EXPORT Error FileErrorToNetError(base::File::Error file_error);
60 
61 }  // namespace net
62 
63 #endif  // NET_BASE_NET_ERRORS_H__
64