Exception.hpp 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /**
  2. * @file artis/utils/Exception.hpp
  3. * @author See the AUTHORS or Authors.txt file
  4. */
  5. /*
  6. * Copyright (C) 2012-2019 ULCO http://www.univ-littoral.fr
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #ifndef ARTIS_UTILS_EXCEPTION_HPP
  22. #define ARTIS_UTILS_EXCEPTION_HPP
  23. #include <boost/format.hpp>
  24. #include <stdexcept>
  25. namespace artis {
  26. namespace utils {
  27. class BaseError : public std::runtime_error {
  28. public:
  29. explicit BaseError(const std::string& argv = std::string())
  30. :std::runtime_error(argv) { }
  31. explicit BaseError(const boost::format& argv)
  32. :std::runtime_error(argv.str()) { }
  33. };
  34. class FileError : public BaseError {
  35. public:
  36. explicit FileError(const std::string& argv = std::string())
  37. :BaseError(argv) { }
  38. explicit FileError(const boost::format& argv)
  39. :BaseError(argv) { }
  40. };
  41. class ParseError : public BaseError {
  42. public:
  43. explicit ParseError(const std::string& argv = std::string())
  44. :BaseError(argv) { }
  45. explicit ParseError(const boost::format& argv)
  46. :BaseError(argv) { }
  47. };
  48. class ReadError : public BaseError {
  49. public:
  50. explicit ReadError(const std::string& argv = std::string())
  51. :BaseError(argv) { }
  52. explicit ReadError(const boost::format& argv)
  53. :BaseError(argv) { }
  54. };
  55. class InvalidFileFormat : public BaseError {
  56. public:
  57. explicit InvalidFileFormat(const std::string& argv = std::string())
  58. :BaseError(argv) { }
  59. explicit InvalidFileFormat(const boost::format& argv)
  60. :BaseError(argv) { }
  61. };
  62. class ErrorInContextFile : public BaseError {
  63. public:
  64. explicit ErrorInContextFile(const std::string& argv = std::string())
  65. :BaseError(argv) { }
  66. explicit ErrorInContextFile(const boost::format& argv)
  67. :BaseError(argv) { }
  68. };
  69. class InvalidGet : public BaseError {
  70. public:
  71. explicit InvalidGet(const std::string& argv = std::string())
  72. :BaseError(argv) { }
  73. explicit InvalidGet(const boost::format& argv)
  74. :BaseError(argv) { }
  75. };
  76. }
  77. }
  78. #endif