xlnt
exceptions.hpp
1 // Copyright (c) 2014-2022 Thomas Fussell
2 // Copyright (c) 2010-2015 openpyxl
3 // Copyright (c) 2024 xlnt-community
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 // THE SOFTWARE
22 //
23 // @license: http://www.opensource.org/licenses/mit-license.php
24 // @author: see AUTHORS file
25 
26 #pragma once
27 
28 #include <cstdint>
29 #include <stdexcept>
30 
31 #include <xlnt/xlnt_config.hpp>
32 #include <xlnt/cell/index_types.hpp>
33 
34 namespace xlnt {
35 
39 class XLNT_API exception : public std::runtime_error
40 {
41 public:
46  explicit exception(const std::string &message);
47 
51  exception(const exception &) = default;
52 
56  ~exception() override;
57 
62  void message(const std::string &message);
63 
67  std::string message();
68 
69 private:
73  std::string message_;
74 };
75 
79 class XLNT_API invalid_parameter : public exception
80 {
81 public:
86 
90  invalid_parameter(const invalid_parameter &) = default;
91 
95  ~invalid_parameter() override;
96 };
97 
101 class XLNT_API invalid_sheet_title : public exception
102 {
103 public:
107  explicit invalid_sheet_title(const std::string &title);
108 
112  invalid_sheet_title(const invalid_sheet_title &) = default;
113 
117  ~invalid_sheet_title() override;
118 };
119 
123 class XLNT_API invalid_file : public exception
124 {
125 public:
130  explicit invalid_file(const std::string &filename);
131 
135  invalid_file(const invalid_file &) = default;
136 
140  ~invalid_file() override;
141 };
142 
147 class XLNT_API illegal_character : public exception
148 {
149 public:
153  explicit illegal_character(char c);
154 
158  illegal_character(const illegal_character &) = default;
159 
163  ~illegal_character() override;
164 };
165 
169 class XLNT_API invalid_data_type : public exception
170 {
171 public:
176 
180  invalid_data_type(const invalid_data_type &) = default;
181 
185  ~invalid_data_type() override;
186 };
187 
191 class XLNT_API invalid_column_index : public exception
192 {
193 public:
198 
202  invalid_column_index(const invalid_column_index &) = default;
203 
207  ~invalid_column_index() override;
208 };
209 
213 class XLNT_API invalid_cell_reference : public exception
214 {
215 public:
220 
224  explicit invalid_cell_reference(const std::string &reference_string);
225 
230 
234  ~invalid_cell_reference() override;
235 };
236 
240 class XLNT_API invalid_attribute : public exception
241 {
242 public:
246  explicit invalid_attribute(const char *optional_message = nullptr);
247 
251  invalid_attribute(const invalid_attribute &) = default;
252 
256  ~invalid_attribute() override;
257 };
258 
262 class XLNT_API key_not_found : public exception
263 {
264 public:
268  key_not_found();
269 
273  key_not_found(const key_not_found &) = default;
274 
278  ~key_not_found() override;
279 };
280 
284 class XLNT_API no_visible_worksheets : public exception
285 {
286 public:
291 
295  no_visible_worksheets(const no_visible_worksheets &) = default;
296 
300  ~no_visible_worksheets() override;
301 };
302 
306 class XLNT_API unhandled_switch_case : public exception
307 {
308 public:
313 
317  unhandled_switch_case(const unhandled_switch_case &) = default;
318 
322  ~unhandled_switch_case() override;
323 };
324 
328 class XLNT_API unsupported : public exception
329 {
330 public:
335  explicit unsupported(const std::string &message);
336 
340  unsupported(const unsupported &) = default;
341 
345  ~unsupported() override;
346 };
347 
348 } // namespace xlnt
Exception for any data type inconsistencies.
Definition: exceptions.hpp:169
Exception for a workbook with no visible worksheets
Definition: exceptions.hpp:284
Exception for attempting to use a feature which is not supported
Definition: exceptions.hpp:328
std::uint32_t row_t
All rows should be referred to by an instance of this type.
Definition: index_types.hpp:41
The data submitted which cannot be used directly in Excel files. It must be removed or escaped...
Definition: exceptions.hpp:147
Enumerates the possible types a cell can be determined by it&#39;s current value.
Definition: cell.hpp:37
Exception for a bad parameter value
Definition: exceptions.hpp:79
Exception when setting a class&#39;s attribute to an invalid value
Definition: exceptions.hpp:240
Exception for bad sheet names.
Definition: exceptions.hpp:101
Exception for a key that doesn&#39;t exist in a container
Definition: exceptions.hpp:262
Exception for bad column indices in A1-style cell references.
Definition: exceptions.hpp:191
Parent type of all custom exceptions thrown in this library.
Definition: exceptions.hpp:39
Exception for trying to open a non-XLSX file.
Definition: exceptions.hpp:123
Columns can be referred to as a string A,B,...Z,AA,AB,..,ZZ,AAA,...,ZZZ or as a 1-indexed index...
Definition: index_types.hpp:48
Debug exception for a switch that fell through to the default case
Definition: exceptions.hpp:306
Exception for converting between numeric and A1-style cell references.
Definition: exceptions.hpp:213