StormByte-Config 2.0.0
C++26 configuration-document 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-Config.
5 *
6 * StormByte-Config 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-Config source in this
20 * repository. They do not cover other StormByte modules or any third-party
21 * material shipped with this repository. The bundled StormByte Base tree
22 * under thirdparty/ 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-Config 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-Config. 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
44
45#include <string>
46#include <string_view>
47#include <utility>
48
52namespace StormByte::Config {
58 public:
65 template <typename... Args>
66 explicit Exception(std::format_string<Args...> fmt, Args&&... args)
67 : StormByte::Exception(StormByte::Exception::Path{"Config"}, fmt, std::forward<Args>(args)...) {}
68
73 explicit Exception(std::string message)
74 : StormByte::Exception(StormByte::Exception::Path{"Config"}, "{}", std::move(message)) {}
75
84 Exception(std::string_view path, std::string message)
85 : StormByte::Exception(StormByte::Exception::Path{path}, "{}", std::move(message)) {}
86
91 Exception(const Exception& other) = default;
92
97 Exception(Exception&& other) noexcept = default;
98
102 ~Exception() noexcept override;
103
109 Exception& operator=(const Exception& other) = default;
110
116 Exception& operator=(Exception&& other) noexcept = default;
117 };
118
124 public:
125 using Exception::Exception;
126
130 ~WrongValueTypeConversion() noexcept override;
131 };
132
138 public:
139 using Exception::Exception;
140
144 ~ValueFailure() noexcept override;
145 };
146
152 public:
153 using Exception::Exception;
154
158 ~InvalidName() noexcept override;
159 };
160
166 public:
167 using Exception::Exception;
168
172 ~InvalidPath() noexcept override;
173 };
174
180 public:
181 using Exception::Exception;
182
186 ~ParseError() noexcept override;
187 };
188
194 public:
195 using Exception::Exception;
196
200 ~ItemNotFound() noexcept override;
201 };
202
208 public:
209 using Exception::Exception;
210
214 ~ItemAlreadyExists() noexcept override;
215 };
216
222 public:
223 using Exception::Exception;
224
228 ~ItemNameAlreadyExists() noexcept override;
229 };
230
236 public:
237 using Exception::Exception;
238
242 ~OutOfBounds() noexcept override;
243 };
244}
Root exception for Config.
Definition exception.hxx:57
Exception(std::format_string< Args... > fmt, Args &&... args)
Format under StormByte.Config.
Definition exception.hxx:66
Exception(std::string_view path, std::string message)
Plain message under an explicit path.
Definition exception.hxx:84
Exception(const Exception &other)=default
Copy constructor.
~Exception() noexcept override
Destructor.
Exception(std::string message)
Format a plain message under StormByte.Config.
Definition exception.hxx:73
Exception(Exception &&other) noexcept=default
Move constructor.
Thrown when an invalid name is used for an item.
Definition exception.hxx:151
~InvalidName() noexcept override
Destructor.
Thrown when an invalid path is used for an item.
Definition exception.hxx:165
~InvalidPath() noexcept override
Destructor.
Thrown when attempting to add an item that already exists.
Definition exception.hxx:207
~ItemAlreadyExists() noexcept override
Destructor.
Thrown when an item's name conflicts with an existing name.
Definition exception.hxx:221
~ItemNameAlreadyExists() noexcept override
Destructor.
Thrown when an item cannot be found by its path or name.
Definition exception.hxx:193
~ItemNotFound() noexcept override
Destructor.
Thrown when an index is out of bounds.
Definition exception.hxx:235
~OutOfBounds() noexcept override
Destructor.
Thrown when a parsing error occurs in a configuration file.
Definition exception.hxx:179
~ParseError() noexcept override
Destructor.
Thrown when setting a value fails due to type mismatch.
Definition exception.hxx:137
~ValueFailure() noexcept override
Destructor.
Thrown when a value is converted to an incorrect type.
Definition exception.hxx:123
~WrongValueTypeConversion() noexcept override
Destructor.
Config module of the StormByte suite.
Definition alias.hxx:49
STL namespace.
#define STORMBYTE_CONFIG_PUBLIC
Definition visibility.h:52