StormByte-Database 2.0.0
C++26 database module of the StormByte suite
 
Loading...
Searching...
No Matches
exception.hxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024-2026 David C. Manuelda (StormBytePP)
3 *
4 * This file is part of StormByte-Database.
5 *
6 * StormByte-Database original source is dual-licensed:
7 *
8 * 1. GNU Lesser General Public License v3.0 (or later)
9 * You may redistribute and/or modify this file under the terms of the
10 * GNU Lesser General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option)
12 * any later version.
13 *
14 * 2. Commercial license
15 * Alternatively, this file may be used under the terms of a commercial
16 * license agreement with the copyright holder
17 * (David C. Manuelda <StormByte@gmail.com>).
18 *
19 * Both licenses apply only to original StormByte-Database source in this
20 * repository. They do not cover other StormByte modules or any third-party
21 * material shipped with this repository (including everything under
22 * thirdparty/, and in particular the bundled StormByte-Logger tree and
23 * the PostgreSQL, MariaDB and SQLite trees), which remain under their own
24 * licenses.
25 *
26 * Neither license grants any patent rights. Any patent licenses required
27 * to use this software or third-party components must be obtained separately
28 * from the patent holders.
29 *
30 * StormByte-Database is distributed in the hope that it will be useful,
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 * GNU Lesser General Public License for more details.
34 *
35 * You should have received a copy of the GNU Lesser General Public License
36 * version 3 along with StormByte-Database. If not, see
37 * <https://www.gnu.org/licenses/lgpl-3.0.html>.
38 *
39 * SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-StormByte-Commercial
40 */
41
42#pragma once
43
46#include <StormByte/size.hxx>
47
48#include <format>
49#include <string>
50#include <string_view>
51#include <utility>
52
57namespace StormByte {
62 namespace Database {
68 public:
73 explicit Exception(std::string_view message);
74
81 template <typename... Args>
82 Exception(std::format_string<Args...> fmt, Args &&...args) : StormByte::Exception(StormByte::Exception::Path{"Database"}, fmt, std::forward<Args>(args)...) {}
83
87 virtual ~Exception() noexcept override;
88
89 protected:
97 template <typename... Args>
98 Exception(StormByte::Exception::Path path, std::format_string<Args...> fmt, Args &&...args) : StormByte::Exception(path, fmt, std::forward<Args>(args)...) {}
99 };
100
106 public:
111 ConnectionError(std::string_view error);
112
116 ~ConnectionError() noexcept override;
117 };
118
124 public:
129 WrongValueType(std::string_view error);
130
134 ~WrongValueType() noexcept override;
135
143 template <typename... Args>
144 WrongValueType(std::string_view component, std::format_string<Args...> fmt, Args &&...args) : Exception(StormByte::Exception::Path{std::string{"Database.WrongValueType."}.append(component)}, fmt, std::forward<Args>(args)...) {}
145 };
146
152 public:
157 ColumnNotFound(std::string_view column);
158
162 ~ColumnNotFound() noexcept override;
163 };
164
170 public:
177
181 ~OutOfBounds() noexcept override;
182 };
183
189 public:
194 QueryException(std::string_view error);
195
199 ~QueryException() noexcept override;
200
208 template <typename... Args>
209 QueryException(std::string_view component, std::format_string<Args...> fmt, Args &&...args) : Exception(StormByte::Exception::Path{std::string{"Database.Query."}.append(component)}, fmt, std::forward<Args>(args)...) {}
210 };
211
217 public:
222 UnknownSTMT(std::string_view name);
223
227 ~UnknownSTMT() noexcept override;
228 };
229
235 public:
240 ExecuteError(std::string_view error);
241
245 ~ExecuteError() noexcept override;
246 };
247
253 public:
258 TransactionError(std::string_view error);
259
263 ~TransactionError() noexcept override;
264 };
265 }
266}
Column name missing from a Row.
Definition exception.hxx:151
~ColumnNotFound() noexcept override
Destructor.
ColumnNotFound(std::string_view column)
Construct from the missing name.
Connection failed.
Definition exception.hxx:105
ConnectionError(std::string_view error)
Construct from a backend message.
~ConnectionError() noexcept override
Destructor.
Base exception for the Database module.
Definition exception.hxx:67
Exception(std::format_string< Args... > fmt, Args &&...args)
Construct with a formatted message.
Definition exception.hxx:82
virtual ~Exception() noexcept override
Destructor.
Exception(std::string_view message)
Construct with an unformatted message.
Query or statement execution failed.
Definition exception.hxx:234
ExecuteError(std::string_view error)
Construct from a backend message.
~ExecuteError() noexcept override
Destructor.
Column index out of range.
Definition exception.hxx:169
~OutOfBounds() noexcept override
Destructor.
OutOfBounds(StormByte::Size pos, StormByte::Size size)
Construct from index and size.
Base for query errors.
Definition exception.hxx:188
QueryException(std::string_view error)
Construct from an error message.
~QueryException() noexcept override
Destructor.
Beginning a database transaction failed.
Definition exception.hxx:252
TransactionError(std::string_view error)
Construct from the failure reason.
~TransactionError() noexcept override
Destructor.
Prepared statement name is not registered.
Definition exception.hxx:216
UnknownSTMT(std::string_view name)
Construct from the statement name.
~UnknownSTMT() noexcept override
Destructor.
Value accessed as the wrong type.
Definition exception.hxx:123
~WrongValueType() noexcept override
Destructor.
WrongValueType(std::string_view error)
Construct from an error message.
Root namespace of the StormByte C++ suite.
STL namespace.
#define STORMBYTE_DATABASE_PUBLIC
Definition visibility.h:54