StormByte 3.0.0
C++26 foundation 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 is the base for StormByte Suite libraries.
5 *
6 * StormByte 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 source in this repository.
20 * They do not cover other StormByte modules or any third-party material
21 * shipped with this repository (including everything under thirdparty/),
22 * which remains under its own license.
23 *
24 * Neither license grants any patent rights. Any patent licenses required
25 * to use this software or third-party components must be obtained separately
26 * from the patent holders.
27 *
28 * StormByte is distributed in the hope that it will be useful,
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 * GNU Lesser General Public License for more details.
32 *
33 * You should have received a copy of the GNU Lesser General Public License
34 * version 3 along with StormByte. If not, see
35 * <https://www.gnu.org/licenses/lgpl-3.0.html>.
36 *
37 * SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-StormByte-Commercial
38 */
39
40#pragma once
41
45
46#include <string_view>
47#include <utility>
48
53namespace StormByte {
54
68 public:
73 explicit Exception(std::string_view message);
74
75
80 Exception(const Exception& other);
81
86 Exception(Exception&& other) noexcept;
87
91 virtual ~Exception() noexcept;
92
98 Exception& operator=(const Exception& other);
99
105 Exception& operator=(Exception&& other) noexcept;
106
111 virtual const char* what() const noexcept;
112
113 protected:
119 struct Path {
120 std::string_view text;
121
126 explicit constexpr Path(std::string_view value = {}) noexcept: text(value) {}
127 };
128
134 Exception() noexcept;
135
141 Exception(Path path, std::string_view message);
142
148 Exception(Path path, Safe::String&& message);
149
157 template <typename... Args>
158 requires (sizeof...(Args) >= 1)
159 Exception(Path path, std::string_view pattern, Args&&... args)
160 : Exception(path, Safe::String::ReplaceToken(pattern, std::forward<Args>(args)...)) {}
161
162 private:
163 Safe::String m_what;
164 };
165
173 public:
178 explicit DeserializeError(std::string_view message);
179
180
187 template <typename... Args>
188 requires (sizeof...(Args) >= 1)
189 DeserializeError(std::string_view pattern, Args&&... args)
190 : Exception(Path{}, pattern, std::forward<Args>(args)...) {}
191
197
203
207 ~DeserializeError() noexcept override;
208
214 DeserializeError& operator=(const DeserializeError& other);
215
221 DeserializeError& operator=(DeserializeError&& other) noexcept;
222 };
223
231 public:
236 explicit OperationError(std::string_view message);
237
238
245 template <typename... Args>
246 requires (sizeof...(Args) >= 1)
247 OperationError(std::string_view pattern, Args&&... args)
248 : Exception(Path{}, pattern, std::forward<Args>(args)...) {}
249
255
261
265 ~OperationError() noexcept override;
266
272 OperationError& operator=(const OperationError& other);
273
279 OperationError& operator=(OperationError&& other) noexcept;
280 };
281
289 public:
294 explicit Base64Error(std::string_view message);
295
296
303 template <typename... Args>
304 requires (sizeof...(Args) >= 1)
305 Base64Error(std::string_view pattern, Args&&... args)
306 : Exception(Path{}, pattern, std::forward<Args>(args)...) {}
307
313
318 Base64Error(Base64Error&& other) noexcept;
319
323 ~Base64Error() noexcept override;
324
330 Base64Error& operator=(const Base64Error& other);
331
337 Base64Error& operator=(Base64Error&& other) noexcept;
338 };
339}
Base64Error(const Base64Error &other)
Copy constructor.
Base64Error(std::string_view message)
Copy a body into StormByte: message.
Base64Error(std::string_view pattern, Args &&... args)
Replace literal {} in pattern.
Definition exception.hxx:305
~Base64Error() noexcept override
Destructor.
Base64Error(Base64Error &&other) noexcept
Move constructor.
DeserializeError(std::string_view pattern, Args &&... args)
Replace literal {} in pattern.
Definition exception.hxx:189
~DeserializeError() noexcept override
Destructor.
DeserializeError(DeserializeError &&other) noexcept
Move constructor.
DeserializeError(std::string_view message)
Copy a body into StormByte: message.
DeserializeError(const DeserializeError &other)
Copy constructor.
Exception(Exception &&other) noexcept
Move constructor.
Exception(const Exception &other)
Copy constructor.
Exception() noexcept
Construct without allocating message storage.
Exception(std::string_view message)
Copies text into StormByte: message.
virtual const char * what() const noexcept
Message pointer.
virtual ~Exception() noexcept
Destructor.
~OperationError() noexcept override
Destructor.
OperationError(const OperationError &other)
Copy constructor.
OperationError(OperationError &&other) noexcept
Move constructor.
OperationError(std::string_view message)
Copy a body into StormByte: message.
OperationError(std::string_view pattern, Args &&... args)
Replace literal {} in pattern.
Definition exception.hxx:247
Owned UTF-8 text.
Definition string.hxx:113
Owned values that cross a DLL without the caller's CRT.
Root namespace of the StormByte suite.
STL namespace.
Segments under StormByte, already joined with a dot.
Definition exception.hxx:119
constexpr Path(std::string_view value={}) noexcept
Wraps value.
Definition exception.hxx:126
std::string_view text
Joined segments. Empty means the root.
Definition exception.hxx:120
#define STORMBYTE_PUBLIC
Definition visibility.h:52