exceptions.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. // Copyright (c) 2014-2021 Thomas Fussell
  2. // Copyright (c) 2010-2015 openpyxl
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE
  21. //
  22. // @license: http://www.opensource.org/licenses/mit-license.php
  23. // @author: see AUTHORS file
  24. #include <xlnt/utils/exceptions.hpp>
  25. namespace xlnt {
  26. exception::exception(const std::string &message)
  27. : std::runtime_error("xlnt::exception : " + message)
  28. {
  29. this->message(message);
  30. }
  31. exception::~exception() = default;
  32. void exception::message(const std::string &message)
  33. {
  34. message_ = message;
  35. }
  36. std::string exception::message()
  37. {
  38. return message_;
  39. }
  40. unhandled_switch_case::unhandled_switch_case()
  41. : xlnt::exception("unhandled switch case")
  42. {
  43. }
  44. unhandled_switch_case::~unhandled_switch_case()
  45. {
  46. }
  47. invalid_sheet_title::invalid_sheet_title(const std::string &title)
  48. : exception(std::string("bad worksheet title: ") + title)
  49. {
  50. }
  51. invalid_sheet_title::~invalid_sheet_title()
  52. {
  53. }
  54. invalid_column_index::invalid_column_index()
  55. : exception("column string index error")
  56. {
  57. }
  58. invalid_column_index::~invalid_column_index()
  59. {
  60. }
  61. invalid_data_type::invalid_data_type()
  62. : exception("data type error")
  63. {
  64. }
  65. invalid_data_type::~invalid_data_type()
  66. {
  67. }
  68. invalid_file::invalid_file(const std::string &filename)
  69. : exception(std::string("couldn't open file: (") + filename + ")")
  70. {
  71. }
  72. invalid_file::~invalid_file()
  73. {
  74. }
  75. invalid_cell_reference::invalid_cell_reference(column_t column, row_t row)
  76. : exception(
  77. std::string("bad cell coordinates: (") + std::to_string(column.index) + ", " + std::to_string(row) + ")")
  78. {
  79. }
  80. invalid_cell_reference::invalid_cell_reference(const std::string &coord_string)
  81. : exception(std::string("bad cell coordinates: (") + (coord_string.empty() ? "<empty>" : coord_string) + ")")
  82. {
  83. }
  84. invalid_cell_reference::~invalid_cell_reference()
  85. {
  86. }
  87. illegal_character::illegal_character(char c)
  88. : exception(std::string("illegal character: (") + std::to_string(static_cast<unsigned char>(c)) + ")")
  89. {
  90. }
  91. illegal_character::~illegal_character()
  92. {
  93. }
  94. invalid_parameter::invalid_parameter()
  95. : exception("invalid parameter")
  96. {
  97. }
  98. invalid_parameter::~invalid_parameter()
  99. {
  100. }
  101. invalid_attribute::invalid_attribute()
  102. : exception("bad attribute")
  103. {
  104. }
  105. invalid_attribute::~invalid_attribute()
  106. {
  107. }
  108. key_not_found::key_not_found()
  109. : exception("key not found in container")
  110. {
  111. }
  112. key_not_found::~key_not_found()
  113. {
  114. }
  115. no_visible_worksheets::no_visible_worksheets()
  116. : exception("workbook needs at least one non-hidden worksheet to be saved")
  117. {
  118. }
  119. no_visible_worksheets::~no_visible_worksheets()
  120. {
  121. }
  122. unsupported::unsupported(const std::string &message)
  123. : exception(message)
  124. {
  125. }
  126. unsupported::~unsupported()
  127. {
  128. }
  129. } // namespace xlnt