net_errors.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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.
  4. #ifndef NET_BASE_NET_ERRORS_H__
  5. #define NET_BASE_NET_ERRORS_H__
  6. #include <string>
  7. #include "base/files/file.h"
  8. #include "base/logging.h"
  9. #include "net/base/net_export.h"
  10. namespace net {
  11. // Error values are negative.
  12. enum Error {
  13. // No error. Change NetError.template after changing value.
  14. OK = 0,
  15. #define NET_ERROR(label, value) ERR_ ## label = value,
  16. #include "net/base/net_error_list.h"
  17. #undef NET_ERROR
  18. // The value of the first certificate error code.
  19. ERR_CERT_BEGIN = ERR_CERT_COMMON_NAME_INVALID,
  20. };
  21. // Returns a textual representation of the error code for logging purposes.
  22. NET_EXPORT std::string ErrorToString(int error);
  23. // Same as above, but leaves off the leading "net::".
  24. NET_EXPORT std::string ErrorToShortString(int error);
  25. // Returns a textual representation of the error code and the extended eror
  26. // code.
  27. NET_EXPORT std::string ExtendedErrorToString(int error,
  28. int extended_error_code);
  29. // Returns true if |error| is a certificate error code. Note this does not
  30. // include errors for client certificates.
  31. NET_EXPORT bool IsCertificateError(int error);
  32. // Returns true if |error| is a client certificate authentication error. This
  33. // does not include ERR_SSL_PROTOCOL_ERROR which may also signal a bad client
  34. // certificate.
  35. NET_EXPORT bool IsClientCertificateError(int error);
  36. // Returns true if |error| is an error from hostname resolution.
  37. NET_EXPORT bool IsHostnameResolutionError(int error);
  38. // Returns true if |error| means that the request has been blocked.
  39. NET_EXPORT bool IsRequestBlockedError(int error);
  40. // Map system error code to Error.
  41. NET_EXPORT Error MapSystemError(logging::SystemErrorCode os_error);
  42. // A convenient function to translate file error to net error code.
  43. NET_EXPORT Error FileErrorToNetError(base::File::Error file_error);
  44. } // namespace net
  45. #endif // NET_BASE_NET_ERRORS_H__