blob: d2807f539998ad17d7128d54685e5fee379887a0 [file] [log] [blame]
[email protected]ed2e766d2012-07-25 00:10:511// Copyright (c) 2012 The Chromium Authors. All rights reserved.
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#include <vector>
10
[email protected]141bcc52014-01-27 21:36:0011#include "base/files/file.h"
pkasting32c741522014-11-26 01:03:5612#include "base/logging.h"
[email protected]172da1b2011-08-12 15:52:2613#include "net/base/net_export.h"
initial.commit586acc5fe2008-07-26 22:42:5214
15namespace net {
16
initial.commit586acc5fe2008-07-26 22:42:5217// Error values are negative.
[email protected]e7b055b2008-08-06 03:09:1418enum Error {
Marcin WiÄ…cek1a85c302019-05-01 21:41:4119 // No error. Change NetError.template after changing value.
initial.commit586acc5fe2008-07-26 22:42:5220 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]3030374e32014-08-07 16:12:0631NET_EXPORT std::string ErrorToString(int error);
32
33// Same as above, but leaves off the leading "net::".
34NET_EXPORT std::string ErrorToShortString(int error);
initial.commit586acc5fe2008-07-26 22:42:5235
Brad Lassey16c13f72018-03-19 19:37:5036// Returns a textual representation of the error code and the extended eror
37// code.
38NET_EXPORT std::string ExtendedErrorToString(int error,
39 int extended_error_code);
40
Eric Romane28b60272019-10-09 19:22:1741// Returns true if |error| is a certificate error code. Note this does not
42// include errors for client certificates.
[email protected]3030374e32014-08-07 16:12:0643NET_EXPORT bool IsCertificateError(int error);
initial.commit586acc5fe2008-07-26 22:42:5244
davidben3a92a96b2014-11-07 23:18:0545// 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.
48NET_EXPORT bool IsClientCertificateError(int error);
49
dalykda475cee2020-01-17 23:45:3650// Returns true if |error| is an error from hostname resolution.
51NET_EXPORT bool IsHostnameResolutionError(int error);
tfarina995fb182016-10-05 21:03:4452
Antonio Sartorid8ec8812020-06-16 12:47:2453// Returns true if |error| means that the request has been blocked.
54NET_EXPORT bool IsRequestBlockedError(int error);
55
[email protected]051e4ec2011-03-15 20:46:3256// Map system error code to Error.
pkasting32c741522014-11-26 01:03:5657NET_EXPORT Error MapSystemError(logging::SystemErrorCode os_error);
[email protected]051e4ec2011-03-15 20:46:3258
[email protected]141bcc52014-01-27 21:36:0059// A convenient function to translate file error to net error code.
60NET_EXPORT Error FileErrorToNetError(base::File::Error file_error);
[email protected]ed2e766d2012-07-25 00:10:5161
initial.commit586acc5fe2008-07-26 22:42:5262} // namespace net
63
64#endif // NET_BASE_NET_ERRORS_H__