// Copyright (c) 2014-2018 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, WRISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE // // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file #pragma once #include #include #include #include namespace xlnt { /// /// Parent type of all custom exceptions thrown in this library. /// class XLNT_API exception : public std::runtime_error { public: /// /// Constructs an exception with a message. This message will be /// returned by std::exception::what(), an inherited member of this class. /// exception(const std::string &message); /// /// Default copy constructor. /// exception(const exception &) = default; /// /// Destructor /// virtual ~exception(); /// /// Sets the message after the xlnt::exception is constructed. This can show /// more specific information than std::exception::what(). /// void message(const std::string &message); private: /// /// The exception message /// std::string message_; }; /// /// Exception for a bad parameter value /// class XLNT_API invalid_parameter : public exception { public: /// /// Default constructor. /// invalid_parameter(); /// /// Default copy constructor. /// invalid_parameter(const invalid_parameter &) = default; /// /// Destructor /// virtual ~invalid_parameter(); }; /// /// Exception for bad sheet names. /// class XLNT_API invalid_sheet_title : public exception { public: /// /// Default constructor. /// invalid_sheet_title(const std::string &title); /// /// Default copy constructor. /// invalid_sheet_title(const invalid_sheet_title &) = default; /// /// Destructor /// virtual ~invalid_sheet_title(); }; /// /// Exception when a referenced number format is not in the stylesheet. /// class XLNT_API missing_number_format : public exception { public: /// /// Default constructor. /// missing_number_format(); /// /// Default copy constructor. /// missing_number_format(const missing_number_format &) = default; /// /// Destructor /// virtual ~missing_number_format(); }; /// /// Exception for trying to open a non-XLSX file. /// class XLNT_API invalid_file : public exception { public: /// /// Constructs an invalid_file exception thrown when attempt to access /// the given filename. /// invalid_file(const std::string &filename); /// /// Default copy constructor. /// invalid_file(const invalid_file &) = default; /// /// Destructor /// virtual ~invalid_file(); }; /// /// The data submitted which cannot be used directly in Excel files. It /// must be removed or escaped. /// class XLNT_API illegal_character : public exception { public: /// /// Constructs an illegal_character exception thrown as a result of the given character. /// illegal_character(char c); /// /// Default copy constructor. /// illegal_character(const illegal_character &) = default; /// /// Destructor /// virtual ~illegal_character(); }; /// /// Exception for any data type inconsistencies. /// class XLNT_API invalid_data_type : public exception { public: /// /// Default constructor. /// invalid_data_type(); /// /// Default copy constructor. /// invalid_data_type(const invalid_data_type &) = default; /// /// Destructor /// virtual ~invalid_data_type(); }; /// /// Exception for bad column indices in A1-style cell references. /// class XLNT_API invalid_column_index : public exception { public: /// /// Default constructor. /// invalid_column_index(); /// /// Default copy constructor. /// invalid_column_index(const invalid_column_index &) = default; /// /// Destructor /// virtual ~invalid_column_index(); }; /// /// Exception for converting between numeric and A1-style cell references. /// class XLNT_API invalid_cell_reference : public exception { public: /// /// Constructs an invalid_cell_reference exception for the given column and row. /// invalid_cell_reference(column_t column, row_t row); /// /// Constructs an invalid_cell_reference exception for the given string. /// invalid_cell_reference(const std::string &reference_string); /// /// Default copy constructor. /// invalid_cell_reference(const invalid_cell_reference &) = default; /// /// Destructor /// virtual ~invalid_cell_reference(); }; /// /// Exception when setting a class's attribute to an invalid value /// class XLNT_API invalid_attribute : public exception { public: /// /// Default constructor. /// invalid_attribute(); /// /// Default copy constructor. /// invalid_attribute(const invalid_attribute &) = default; /// /// Destructor /// virtual ~invalid_attribute(); }; /// /// Exception for a key that doesn't exist in a container /// class XLNT_API key_not_found : public exception { public: /// /// Default constructor. /// key_not_found(); /// /// Default copy constructor. /// key_not_found(const key_not_found &) = default; /// /// Destructor /// virtual ~key_not_found(); }; /// /// Exception for a workbook with no visible worksheets /// class XLNT_API no_visible_worksheets : public exception { public: /// /// Default constructor. /// no_visible_worksheets(); /// /// Default copy constructor. /// no_visible_worksheets(const no_visible_worksheets &) = default; /// /// Destructor /// virtual ~no_visible_worksheets(); }; /// /// Debug exception for a switch that fell through to the default case /// class XLNT_API unhandled_switch_case : public exception { public: /// /// Default constructor. /// unhandled_switch_case(); /// /// Default copy constructor. /// unhandled_switch_case(const unhandled_switch_case &) = default; /// /// Destructor /// virtual ~unhandled_switch_case(); }; /// /// Exception for attempting to use a feature which is not supported /// class XLNT_API unsupported : public exception { public: /// /// Constructs an unsupported exception with a message describing the unsupported /// feature. /// unsupported(const std::string &message); /// /// Default copy constructor. /// unsupported(const unsupported &) = default; /// /// Destructor /// virtual ~unsupported(); }; } // namespace xlnt