client_errc.hpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. //
  2. // Copyright (c) 2019-2024 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. #ifndef BOOST_MYSQL_CLIENT_ERRC_HPP
  8. #define BOOST_MYSQL_CLIENT_ERRC_HPP
  9. #include <boost/mysql/error_code.hpp>
  10. #include <boost/mysql/detail/config.hpp>
  11. #include <boost/system/error_category.hpp>
  12. namespace boost {
  13. namespace mysql {
  14. /**
  15. * \brief MySQL client-defined error codes.
  16. * \details These errors are produced by the client itself, rather than the server.
  17. */
  18. enum class client_errc : int
  19. {
  20. /// An incomplete message was received from the server (indicates a deserialization error or
  21. /// packet mismatch).
  22. incomplete_message = 1,
  23. /// An unexpected value was found in a server-received message (indicates a deserialization
  24. /// error or packet mismatch).
  25. protocol_value_error,
  26. /// The server does not support the minimum required capabilities to establish the connection.
  27. server_unsupported,
  28. /// Unexpected extra bytes at the end of a message were received (indicates a deserialization
  29. /// error or packet mismatch).
  30. extra_bytes,
  31. /// Mismatched sequence numbers (usually caused by a packet mismatch).
  32. sequence_number_mismatch,
  33. /// The user employs an authentication plugin not known to this library.
  34. unknown_auth_plugin,
  35. /// The authentication plugin requires the connection to use SSL.
  36. auth_plugin_requires_ssl,
  37. /// The number of parameters passed to the prepared statement does not match the number of
  38. /// actual parameters.
  39. wrong_num_params,
  40. /// The connection mandates SSL, but the server doesn't accept SSL connections.
  41. server_doesnt_support_ssl,
  42. /// The static interface detected a mismatch between your C++ type definitions and what the server
  43. /// returned in the query.
  44. metadata_check_failed,
  45. /// The static interface detected a mismatch between the number of row types passed to `static_results`
  46. /// or `static_execution_state` and the number of resultsets returned by your query.
  47. num_resultsets_mismatch,
  48. /// The StaticRow type passed to read_some_rows does not correspond to the resultset type being read.
  49. row_type_mismatch,
  50. /// The static interface encountered an error when parsing a field into a C++ data structure.
  51. static_row_parsing_error,
  52. /// (EXPERIMENTAL) An operation controlled by Boost.MySQL timed out.
  53. timeout,
  54. /// (EXPERIMENTAL) An operation controlled by Boost.MySQL was cancelled.
  55. cancelled,
  56. /// (EXPERIMENTAL) Getting a connection from a connection_pool failed because the
  57. /// pool is not running. Ensure that you're calling connection_pool::async_run.
  58. pool_not_running,
  59. /// (EXPERIMENTAL) An invalid byte sequence was found while trying to decode a string.
  60. invalid_encoding,
  61. /// (EXPERIMENTAL) A formatting operation could not format one of its arguments.
  62. unformattable_value,
  63. /// (EXPERIMENTAL) A format string containing invalid syntax was provided to a SQL formatting function.
  64. format_string_invalid_syntax,
  65. /// (EXPERIMENTAL) A format string with an invalid byte sequence was provided to a SQL formatting
  66. /// function.
  67. format_string_invalid_encoding,
  68. /// (EXPERIMENTAL) A format string mixes manual (e.g. {0}) and automatic (e.g. {}) indexing.
  69. format_string_manual_auto_mix,
  70. /// (EXPERIMENTAL) The supplied format specifier (e.g. {:i}) is not supported by the type being formatted.
  71. format_string_invalid_specifier,
  72. /// (EXPERIMENTAL) A format argument referenced by a format string was not found. Check the number
  73. /// of format arguments passed and their names.
  74. format_arg_not_found,
  75. /// (EXPERIMENTAL) The character set used by the connection is not known by the client. Use
  76. /// set_character_set or async_set_character_set before invoking operations that require a known charset.
  77. unknown_character_set,
  78. /// (EXPERIMENTAL) An operation attempted to read or write a packet larger than the maximum buffer size.
  79. /// Try increasing \ref any_connection_params::max_buffer_size.
  80. max_buffer_size_exceeded,
  81. };
  82. BOOST_MYSQL_DECL
  83. const boost::system::error_category& get_client_category() noexcept;
  84. /// Creates an \ref error_code from a \ref client_errc.
  85. inline error_code make_error_code(client_errc error)
  86. {
  87. return error_code(static_cast<int>(error), get_client_category());
  88. }
  89. } // namespace mysql
  90. #ifndef BOOST_MYSQL_DOXYGEN
  91. namespace system {
  92. template <>
  93. struct is_error_code_enum<::boost::mysql::client_errc>
  94. {
  95. static constexpr bool value = true;
  96. };
  97. } // namespace system
  98. #endif
  99. } // namespace boost
  100. #ifdef BOOST_MYSQL_HEADER_ONLY
  101. #include <boost/mysql/impl/error_categories.ipp>
  102. #endif
  103. #endif