MySQL Connector/C++
MySQL connector library for C and C++ applications
error.h
1/*
2 * Copyright (c) 2015, 2024, Oracle and/or its affiliates.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2.0, as
6 * published by the Free Software Foundation.
7 *
8 * This program is designed to work with certain software (including
9 * but not limited to OpenSSL) that is licensed under separate terms, as
10 * designated in a particular file or component or in included license
11 * documentation. The authors of MySQL hereby grant you an additional
12 * permission to link the program and your derivative works with the
13 * separately licensed software that they have either included with
14 * the program or referenced in the documentation.
15 *
16 * Without limiting anything contained in the foregoing, this file,
17 * which is part of Connector/C++, is also subject to the
18 * Universal FOSS Exception, version 1.0, a copy of which can be found at
19 * https://oss.oracle.com/licenses/universal-foss-exception.
20 *
21 * This program is distributed in the hope that it will be useful, but
22 * WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
24 * See the GNU General Public License, version 2.0, for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software Foundation, Inc.,
28 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 */
30#ifndef MYSQLX_COMMON_ERROR_H
31#define MYSQLX_COMMON_ERROR_H
32
33/*
34 TODO: Error handling infrastructure for XDevAPI and X DevAPI for C still
35 needs to be done. Current code is just a temporary hack.
36*/
37
38#include "api.h"
39#include "util.h"
40
41PUSH_SYS_WARNINGS
42#include <string>
43#include <stdexcept>
44#include <ostream>
45#include <memory>
46#include <forward_list>
47#include <string.h> // for memcpy
48#include <utility> // std::move etc
49POP_SYS_WARNINGS
50
51
52namespace mysqlx {
53MYSQLX_ABI_BEGIN(2,0)
54
55namespace common {
56
68class Error : public std::runtime_error
69{
70public:
71
72 Error(const char *msg)
73 : std::runtime_error(msg)
74 {}
75};
76
77
78inline
79std::ostream& operator<<(std::ostream &out, const Error &e)
80{
81 out << e.what();
82 return out;
83}
84
85
86inline
87void throw_error(const char *msg)
88{
89 throw Error(msg);
90}
91
92} // common
93
94MYSQLX_ABI_END(2,0)
95} // mysqlx
96
97
98#endif
Base class for connector errors.
Definition: common.h:84
Base class for connector errors.
Definition: error.h:69