blob: 8fe976d4648c5f0a9948a7a9af2a17c7a47e314d [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
17// Error domain of the net module's error codes.
[email protected]172da1b2011-08-12 15:52:2618NET_EXPORT extern const char kErrorDomain[];
initial.commit586acc5fe2008-07-26 22:42:5219
20// Error values are negative.
[email protected]e7b055b2008-08-06 03:09:1421enum Error {
initial.commit586acc5fe2008-07-26 22:42:5222 // No error.
23 OK = 0,
24
25#define NET_ERROR(label, value) ERR_ ## label = value,
26#include "net/base/net_error_list.h"
27#undef NET_ERROR
28
29 // The value of the first certificate error code.
30 ERR_CERT_BEGIN = ERR_CERT_COMMON_NAME_INVALID,
31};
32
33// Returns a textual representation of the error code for logging purposes.
[email protected]3030374e32014-08-07 16:12:0634NET_EXPORT std::string ErrorToString(int error);
35
36// Same as above, but leaves off the leading "net::".
37NET_EXPORT std::string ErrorToShortString(int error);
initial.commit586acc5fe2008-07-26 22:42:5238
39// Returns true if |error| is a certificate error code.
[email protected]3030374e32014-08-07 16:12:0640NET_EXPORT bool IsCertificateError(int error);
initial.commit586acc5fe2008-07-26 22:42:5241
davidben3a92a96b2014-11-07 23:18:0542// Returns true if |error| is a client certificate authentication error. This
43// does not include ERR_SSL_PROTOCOL_ERROR which may also signal a bad client
44// certificate.
45NET_EXPORT bool IsClientCertificateError(int error);
46
tfarina995fb182016-10-05 21:03:4447// Returns true if |error| is a DNS error.
48NET_EXPORT bool IsDnsError(int error);
49
[email protected]051e4ec2011-03-15 20:46:3250// Map system error code to Error.
pkasting32c741522014-11-26 01:03:5651NET_EXPORT Error MapSystemError(logging::SystemErrorCode os_error);
[email protected]051e4ec2011-03-15 20:46:3252
[email protected]141bcc52014-01-27 21:36:0053// A convenient function to translate file error to net error code.
54NET_EXPORT Error FileErrorToNetError(base::File::Error file_error);
[email protected]ed2e766d2012-07-25 00:10:5155
initial.commit586acc5fe2008-07-26 22:42:5256} // namespace net
57
58#endif // NET_BASE_NET_ERRORS_H__