exceptions.hpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // -*- C++ -*-
  2. // Boost general library 'format' ---------------------------
  3. // See http://www.boost.org for updates, documentation, and revision history.
  4. // (C) Samuel Krempp 2001
  5. // krempp@crans.ens-cachan.fr
  6. // Permission to copy, use, modify, sell and
  7. // distribute this software is granted provided this copyright notice appears
  8. // in all copies. This software is provided "as is" without express or implied
  9. // warranty, and with no claim as to its suitability for any purpose.
  10. // ideas taken from Rüdiger Loos's format class
  11. // and Karl Nelson's ofstream (also took its parsing code as basis for printf parsing)
  12. // ------------------------------------------------------------------------------
  13. // exceptions.hpp
  14. // ------------------------------------------------------------------------------
  15. #ifndef BOOST_FORMAT_EXCEPTIONS_HPP
  16. #define BOOST_FORMAT_EXCEPTIONS_HPP
  17. #include <stdexcept>
  18. namespace boost {
  19. namespace io {
  20. // **** exceptions -----------------------------------------------
  21. class format_error : public std::exception
  22. {
  23. public:
  24. format_error() {}
  25. virtual const char *what() const throw()
  26. {
  27. return "boost::format_error: "
  28. "format generic failure";
  29. }
  30. };
  31. class bad_format_string : public format_error
  32. {
  33. public:
  34. bad_format_string() {}
  35. virtual const char *what() const throw()
  36. {
  37. return "boost::bad_format_string: "
  38. "format-string is ill-formed";
  39. }
  40. };
  41. class too_few_args : public format_error
  42. {
  43. public:
  44. too_few_args() {}
  45. virtual const char *what() const throw()
  46. {
  47. return "boost::too_few_args: "
  48. "format-string refered to more arguments than were passed";
  49. }
  50. };
  51. class too_many_args : public format_error
  52. {
  53. public:
  54. too_many_args() {}
  55. virtual const char *what() const throw()
  56. {
  57. return "boost::too_many_args: "
  58. "format-string refered to less arguments than were passed";
  59. }
  60. };
  61. class out_of_range : public format_error
  62. {
  63. public:
  64. out_of_range() {}
  65. virtual const char *what() const throw()
  66. {
  67. return "boost::out_of_range: "
  68. "tried to refer to an argument (or item) number which is out of range, "
  69. "according to the format string.";
  70. }
  71. };
  72. } // namespace io
  73. } // namespace boost
  74. #endif // BOOST_FORMAT_EXCEPTIONS_HPP