blob: 074d9ff3cd292d9fbe9328bab722a821b0f7ef50 [file] [log] [blame]
Avi Drissman64595482022-09-14 20:52:291// Copyright 2012 The Chromium Authors
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit586acc5fe2008-07-26 22:42:524
5#ifndef NET_BASE_NET_ERRORS_H__
6#define NET_BASE_NET_ERRORS_H__
7
[email protected]3030374e32014-08-07 16:12:068#include <string>
[email protected]961fefb2011-05-24 13:59:589
[email protected]141bcc52014-01-27 21:36:0010#include "base/files/file.h"
pkasting32c741522014-11-26 01:03:5611#include "base/logging.h"
[email protected]172da1b2011-08-12 15:52:2612#include "net/base/net_export.h"
initial.commit586acc5fe2008-07-26 22:42:5213
14namespace net {
15
initial.commit586acc5fe2008-07-26 22:42:5216// Error values are negative.
[email protected]e7b055b2008-08-06 03:09:1417enum Error {
Marcin WiÄ…cek1a85c302019-05-01 21:41:4118 // No error. Change NetError.template after changing value.
initial.commit586acc5fe2008-07-26 22:42:5219 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]3030374e32014-08-07 16:12:0630NET_EXPORT std::string ErrorToString(int error);
31
32// Same as above, but leaves off the leading "net::".
33NET_EXPORT std::string ErrorToShortString(int error);
initial.commit586acc5fe2008-07-26 22:42:5234
Brad Lassey16c13f72018-03-19 19:37:5035// Returns a textual representation of the error code and the extended eror
36// code.
37NET_EXPORT std::string ExtendedErrorToString(int error,
38 int extended_error_code);
39
Eric Romane28b60272019-10-09 19:22:1740// Returns true if |error| is a certificate error code. Note this does not
41// include errors for client certificates.
[email protected]3030374e32014-08-07 16:12:0642NET_EXPORT bool IsCertificateError(int error);
initial.commit586acc5fe2008-07-26 22:42:5243
davidben3a92a96b2014-11-07 23:18:0544// 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.
47NET_EXPORT bool IsClientCertificateError(int error);
48
dalykda475cee2020-01-17 23:45:3649// Returns true if |error| is an error from hostname resolution.
50NET_EXPORT bool IsHostnameResolutionError(int error);
tfarina995fb182016-10-05 21:03:4451
Antonio Sartorid8ec8812020-06-16 12:47:2452// Returns true if |error| means that the request has been blocked.
53NET_EXPORT bool IsRequestBlockedError(int error);
54
[email protected]051e4ec2011-03-15 20:46:3255// Map system error code to Error.
pkasting32c741522014-11-26 01:03:5656NET_EXPORT Error MapSystemError(logging::SystemErrorCode os_error);
[email protected]051e4ec2011-03-15 20:46:3257
[email protected]141bcc52014-01-27 21:36:0058// A convenient function to translate file error to net error code.
59NET_EXPORT Error FileErrorToNetError(base::File::Error file_error);
[email protected]ed2e766d2012-07-25 00:10:5160
initial.commit586acc5fe2008-07-26 22:42:5261} // namespace net
62
63#endif // NET_BASE_NET_ERRORS_H__