1 // Copyright (c) 2011 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. 4 5 #ifndef NET_BASE_NET_ERRORS_H__ 6 #define NET_BASE_NET_ERRORS_H__ 7 #pragma once 8 9 #include "base/basictypes.h" 10 11 namespace net { 12 13 // Error domain of the net module's error codes. 14 extern const char kErrorDomain[]; 15 16 // Error values are negative. 17 enum Error { 18 // No error. 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 const char* ErrorToString(int error); 31 32 // Returns true if |error| is a certificate error code. IsCertificateError(int error)33inline bool IsCertificateError(int error) { 34 // Certificate errors are negative integers from net::ERR_CERT_BEGIN 35 // (inclusive) to net::ERR_CERT_END (exclusive) in *decreasing* order. 36 return error <= ERR_CERT_BEGIN && error > ERR_CERT_END; 37 } 38 39 // Map system error code to Error. 40 Error MapSystemError(int os_error); 41 42 } // namespace net 43 44 #endif // NET_BASE_NET_ERRORS_H__ 45