MySQL Connector/C++
MySQL connector library for C and C++ applications
Loading...
Searching...
No Matches
error.h
1/*
2 * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
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 also distributed with certain software (including
9 * but not limited to OpenSSL) that is licensed under separate terms,
10 * as designated in a particular file or component or in included license
11 * documentation. The authors of MySQL hereby grant you an
12 * additional permission to link the program and your derivative works
13 * with the separately licensed software that they have included with
14 * MySQL.
15 *
16 * Without limiting anything contained in the foregoing, this file,
17 * which is part of MySQL Connector/C++, is also subject to the
18 * Universal FOSS Exception, version 1.0, a copy of which can be found at
19 * http://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
31#ifndef MYSQLX_COMMON_ERROR_H
32#define MYSQLX_COMMON_ERROR_H
33
34/*
35 TODO: Error handling infrastructure for XDevAPI and X DevAPI for C still
36 needs to be done. Current code is just a temporary hack.
37*/
38
39#include "api.h"
40#include "util.h"
41
42PUSH_SYS_WARNINGS
43#include <string>
44#include <stdexcept>
45#include <ostream>
46#include <memory>
47#include <forward_list>
48#include <string.h> // for memcpy
49#include <utility> // std::move etc
50POP_SYS_WARNINGS
51
52
53namespace mysqlx {
54MYSQLX_ABI_BEGIN(2,0)
55
56namespace common {
57
69class Error : public std::runtime_error
70{
71public:
72
73 Error(const char *msg)
74 : std::runtime_error(msg)
75 {}
76};
77
78
79inline
80std::ostream& operator<<(std::ostream &out, const Error &e)
81{
82 out << e.what();
83 return out;
84}
85
86
87inline
88void throw_error(const char *msg)
89{
90 throw Error(msg);
91}
92
93} // common
94
95MYSQLX_ABI_END(2,0)
96} // mysqlx
97
98
99#endif
Base class for connector errors.
Definition: common.h:84
Base class for connector errors.
Definition: error.h:70