xlnt - community edition
exceptions.hpp
1 // Copyright (c) 2014-2022 Thomas Fussell
2 // Copyright (c) 2010-2015 openpyxl
3 // Copyright (c) 2024-2026 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 <stdexcept>
29 
30 #include <xlnt/xlnt_config.hpp>
31 #include <xlnt/cell/index_types.hpp>
32 #include <xlnt/utils/variant.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 
52  void message(const std::string &message);
53 
57  const std::string & message();
58 
59 private:
63  std::string message_;
64 };
65 
69 class XLNT_API invalid_parameter : public exception
70 {
71 public:
75  explicit invalid_parameter(const std::string &message);
76 };
77 
81 class XLNT_API invalid_sheet_title : public exception
82 {
83 public:
87  explicit invalid_sheet_title(const std::string &title);
88 };
89 
93 class XLNT_API invalid_file : public exception
94 {
95 public:
100  explicit invalid_file(const std::string &reason);
101 };
102 
107 class XLNT_API illegal_character : public exception
108 {
109 public:
113  explicit illegal_character(char c);
114 };
115 
119 class XLNT_API invalid_data_type : public exception
120 {
121 public:
125  invalid_data_type(const std::string &type);
126 };
127 
131 class XLNT_API invalid_column_index : public exception
132 {
133 public:
137  explicit invalid_column_index(column_t::index_t column_index);
138 
142  explicit invalid_column_index(column_t column);
143 
147  explicit invalid_column_index(const std::string &column_str);
148 };
149 
153 class XLNT_API invalid_cell_reference : public exception
154 {
155 public:
160 
164  explicit invalid_cell_reference(const std::string &reference_string);
165 };
166 
171 class XLNT_API invalid_attribute : public exception
172 {
173 public:
177  explicit invalid_attribute(const std::string &message);
178 };
179 
183 class XLNT_API key_not_found : public exception
184 {
185 public:
189  explicit key_not_found(const std::string &key_name);
190 };
191 
195 class XLNT_API no_visible_worksheets : public exception
196 {
197 public:
202 };
203 
207 class XLNT_API unhandled_switch_case : public exception
208 {
209 public:
215  explicit unhandled_switch_case(long long switch_value);
216 
220  explicit unhandled_switch_case(const std::string &switch_value_string);
221 
227  explicit unhandled_switch_case(const char *switch_value_optional_string = nullptr);
228 };
229 
233 class XLNT_API invalid_password : public exception
234 {
235 public:
239  explicit invalid_password(const std::string &message);
240 };
241 
245 class XLNT_API unsupported : public exception
246 {
247 public:
252  explicit unsupported(const std::string &message);
253 };
254 
258 class XLNT_API encoding_error : public exception
259 {
260 public:
264  explicit encoding_error(const std::string &message);
265 };
266 
270 class XLNT_API bad_variant_access : public exception
271 {
272 public:
276  explicit bad_variant_access(variant::type expected_type, variant::type actual_type);
277 };
278 
279 } // namespace xlnt
Exception for any data type inconsistencies.
Definition: exceptions.hpp:119
type
The possible types a variant can hold.
Definition: variant.hpp:48
Exception for a workbook with no visible worksheets
Definition: exceptions.hpp:195
Exception for attempting to use a feature which is not supported
Definition: exceptions.hpp:245
Exception for invalid (empty, incorrect) passwords
Definition: exceptions.hpp:233
Exception for encoding errors
Definition: exceptions.hpp:258
std::uint32_t index_t
Alias declaration for the internal numeric type of this column.
Definition: index_types.hpp:59
std::uint32_t row_t
All rows should be referred to by an instance of this type. By default, row references range from 1 t...
Definition: index_types.hpp:43
The data submitted which cannot be used directly in Excel files. It must be removed or escaped...
Definition: exceptions.hpp:107
Exception for xlnt::variant access
Definition: exceptions.hpp:270
Enumerates the possible types a cell can be determined by it&#39;s current value.
Definition: cell.hpp:36
Exception for a bad parameter value
Definition: exceptions.hpp:69
Exception when getting a class&#39;s attribute before being set/initialized, or when setting a class&#39;s at...
Definition: exceptions.hpp:171
Exception for bad sheet names.
Definition: exceptions.hpp:81
Exception for a key that doesn&#39;t exist in a container
Definition: exceptions.hpp:183
Exception for bad column indices in A1-style cell references.
Definition: exceptions.hpp:131
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:93
Columns can be referred to as a string A,B,...Z,AA,AB,..,ZZ,AAA,...,XFD or as a 1-indexed index (indi...
Definition: index_types.hpp:53
Debug exception for a switch that fell through to the default case
Definition: exceptions.hpp:207
Exception for converting between numeric and A1-style cell references.
Definition: exceptions.hpp:153