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
43#include <StormByte/size.hxx>
47
48#include <string_view>
49#include <utility>
50
55namespace StormByte {
60 namespace Safe {
68 public:
73 explicit Exception(std::string_view message);
74
75
80 Exception(const Exception& other);
81
86 Exception(Exception&& other) noexcept;
87
91 ~Exception() noexcept override;
92
98 Exception& operator=(const Exception& other);
99
105 Exception& operator=(Exception&& other) noexcept;
106
113 template <typename... Args>
114 requires (sizeof...(Args) >= 1)
115 Exception(std::string_view pattern, Args&&... args)
116 : StormByte::Exception(StormByte::Exception::Path{"Safe"}, pattern, std::forward<Args>(args)...) {}
117
118 protected:
124 Exception() noexcept;
125
126 };
127
135 public:
139 AllocationError() noexcept;
140
145 AllocationError(const AllocationError& other) noexcept;
146
152
156 ~AllocationError() noexcept override;
157
163 AllocationError& operator=(const AllocationError& other) noexcept;
164
170 AllocationError& operator=(AllocationError&& other) noexcept;
171
176 const char* what() const noexcept override;
177 };
178
186 public:
191 explicit ExpiredWeakPointerError(std::string_view message);
192
193
200 template <typename... Args>
201 requires (sizeof...(Args) >= 1)
202 ExpiredWeakPointerError(std::string_view pattern, Args&&... args)
203 : Exception(pattern, std::forward<Args>(args)...) {}
204
210
216
220 ~ExpiredWeakPointerError() noexcept override;
221
228
235 };
236
244 public:
249 explicit OutOfBoundsError(const Size& index);
250
257
263
269
273 ~OutOfBoundsError() noexcept override;
274
280 OutOfBoundsError& operator=(const OutOfBoundsError& other);
281
287 OutOfBoundsError& operator=(OutOfBoundsError&& other) noexcept;
288 };
289
297 public:
302
307 BadOptionalAccess(const BadOptionalAccess& other) noexcept;
308
314
318 ~BadOptionalAccess() noexcept override;
319
325 BadOptionalAccess& operator=(const BadOptionalAccess& other) noexcept;
326
332 BadOptionalAccess& operator=(BadOptionalAccess&& other) noexcept;
333
338 const char* what() const noexcept override;
339 };
340
348 public:
353 explicit BadVariantAccess(std::string_view message);
354
355
362 template <typename... Args>
363 requires (sizeof...(Args) >= 1)
364 BadVariantAccess(std::string_view pattern, Args&&... args)
365 : Exception(pattern, std::forward<Args>(args)...) {}
366
372
378
382 ~BadVariantAccess() noexcept override;
383
389 BadVariantAccess& operator=(const BadVariantAccess& other);
390
396 BadVariantAccess& operator=(BadVariantAccess&& other) noexcept;
397 };
398 }
399}
Base exception type for the suite.
Definition exception.hxx:67
AllocationError() noexcept
Construct an allocation failure.
const char * what() const noexcept override
Return the static message.
const char * what() const noexcept override
Return the static message.
BadOptionalAccess() noexcept
Construct an empty-optional failure.
BadVariantAccess(BadVariantAccess &&other) noexcept
Move constructor.
BadVariantAccess(std::string_view message)
Copy a body into StormByte.Safe: message.
BadVariantAccess(std::string_view pattern, Args &&... args)
Replace literal {} in pattern.
Definition exception.hxx:364
BadVariantAccess(const BadVariantAccess &other)
Copy constructor.
~BadVariantAccess() noexcept override
Destructor.
Exception(std::string_view message)
Copy a body into StormByte.Safe: message.
~Exception() noexcept override
Destructor.
Exception() noexcept
Construct without allocating message storage.
Exception(const Exception &other)
Copy constructor.
Exception(Exception &&other) noexcept
Move constructor.
ExpiredWeakPointerError(const ExpiredWeakPointerError &other)
Copy constructor.
~ExpiredWeakPointerError() noexcept override
Destructor.
ExpiredWeakPointerError(std::string_view pattern, Args &&... args)
Replace literal {} in pattern.
Definition exception.hxx:202
ExpiredWeakPointerError(ExpiredWeakPointerError &&other) noexcept
Move constructor.
ExpiredWeakPointerError(std::string_view message)
Copy a body into StormByte.Safe: message.
OutOfBoundsError(const Size &index)
Report index.
OutOfBoundsError()
Report an out-of-range access that has no numeric bound.
OutOfBoundsError(const OutOfBoundsError &other)
Copy constructor.
~OutOfBoundsError() noexcept override
Destructor.
OutOfBoundsError(OutOfBoundsError &&other) noexcept
Move constructor.
Count of abstract units (uint64_t storage).
Definition size.hxx:107
Owned values that cross a DLL without the caller's CRT.
Root namespace of the StormByte suite.
STL namespace.
Host-width-stable count (uint64_t), implicit only to std::size_t.
Segments under StormByte, already joined with a dot.
Definition exception.hxx:119
#define STORMBYTE_PUBLIC
Definition visibility.h:52