1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "net/base/net_errors.h"
9 const char kErrorDomain
[] = "net";
11 std::string
ErrorToString(int error
) {
12 return "net::" + ErrorToShortString(error
);
15 std::string
ErrorToShortString(int error
) {
19 const char* error_string
;
21 #define NET_ERROR(label, value) \
23 error_string = # label; \
25 #include "net/base/net_error_list.h"
29 error_string
= "<unknown>";
31 return std::string("ERR_") + error_string
;
34 bool IsCertificateError(int error
) {
35 // Certificate errors are negative integers from net::ERR_CERT_BEGIN
36 // (inclusive) to net::ERR_CERT_END (exclusive) in *decreasing* order.
37 // ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN is currently an exception to this
39 return (error
<= ERR_CERT_BEGIN
&& error
> ERR_CERT_END
) ||
40 (error
== ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN
);
43 bool IsClientCertificateError(int error
) {
45 case ERR_BAD_SSL_CLIENT_AUTH_CERT
:
46 case ERR_SSL_CLIENT_AUTH_PRIVATE_KEY_ACCESS_DENIED
:
47 case ERR_SSL_CLIENT_AUTH_CERT_NO_PRIVATE_KEY
:
48 case ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED
:
55 Error
FileErrorToNetError(base::File::Error file_error
) {
57 case base::File::FILE_OK
:
59 case base::File::FILE_ERROR_ACCESS_DENIED
:
60 return ERR_ACCESS_DENIED
;
61 case base::File::FILE_ERROR_INVALID_URL
:
62 return ERR_INVALID_URL
;
63 case base::File::FILE_ERROR_NOT_FOUND
:
64 return ERR_FILE_NOT_FOUND
;