Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.

Error handling and available overloads

This section describes the different error handling strategies you may use with this library, as well as the different overloads available for each function involving network transfers.

This library uses Boost.System error codes and exceptions, like Asio and Beast. Some server-reported errors may include additional diagnostics information. For example, if you issue a query and one of the referenced fields does not exist, the server will return an error message indicating which was the offending field. This library makes these diagnostics available through the following classes and functions:


An object containing this extra diagnostic information about an error. diagnostics::server_message contains the server-generated error string, if any.


An exception that inherits from boost::system::system_error that contains a diagnostics object.


A utility function to check an error_code and throw an error_with_diagnostics if the operation failed.

Every piece of functionality involving network transfers is offered in four versions:

Types of errors

This library defines the following types of errors:

Type of error

Values contained in...

Error category


Client errors

client_errc enum


Failures detected by Boost.MySQL, like corrupt messages.

Common server errors

common_server_errc enum


Errors reported by the server, common to both MySQL and MariaDB. No new codes will be added here, since the two DBs are currently developed independently.

MySQL-specific server errors

Integer codes in


Errors reported by the server, specific to MySQL. New codes will be added in the future.

MariaDB-specific server errors

Integer codes in


Errors reported by the server, specific to MariaDB. New codes will be added in the future.

Note that new codes are added frequently, so server-specific codes are represented as integers, instead of enums.

Security notes on diagnostics

The error message given by diagnostics::server_message may contain user-provided input, and should be treated as untrusted. For certain errors, the MySQL server will include the offending field names and values, which may contain arbitrary input. Please use with caution.

This message may contain non-ASCII characters. It's encoded using the connection's character set.