General Purpose library for Freestanding C++ and POSIX systems
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

116 linhas
1.9 KiB

  1. #pragma once
  2. #include "gp_config.hpp"
  3. namespace gp{
  4. class runtime_error{
  5. protected:
  6. const char* what_str;
  7. public:
  8. runtime_error(const char* what)
  9. : what_str{what}
  10. {}
  11. runtime_error()
  12. {
  13. what_str = "an unknown error has occured";
  14. }
  15. const char* what()
  16. {
  17. return what_str;
  18. }
  19. };
  20. class out_of_range : public runtime_error{
  21. public:
  22. out_of_range(const char* what)
  23. : runtime_error{what}
  24. {}
  25. out_of_range()
  26. : runtime_error{}
  27. {
  28. what_str = "out_of_range error has occured";
  29. }
  30. };
  31. class bad_optional : public runtime_error{
  32. public:
  33. bad_optional(const char* what)
  34. : runtime_error{what}
  35. {}
  36. bad_optional()
  37. : runtime_error{}
  38. {
  39. what_str = "bad_optional error has occured";
  40. }
  41. };
  42. template<typename orig, typename target>
  43. class bad_buffer_cast : public runtime_error{
  44. public:
  45. bad_buffer_cast(const char* what)
  46. : runtime_error{what}
  47. {}
  48. bad_buffer_cast()
  49. : runtime_error{}
  50. {
  51. what_str = "bad_buffer_cast error has occured";
  52. }
  53. };
  54. template<typename Expected>
  55. class bad_variant_access : public runtime_error{
  56. public:
  57. bad_variant_access(const char* what)
  58. : runtime_error{what}
  59. {}
  60. bad_variant_access()
  61. : runtime_error{}
  62. {
  63. what_str = "bad_variant_access error has occured";
  64. }
  65. };
  66. class bad_hashmap_access : public runtime_error{
  67. public:
  68. bad_hashmap_access(const char* what)
  69. : runtime_error{what}
  70. {}
  71. bad_hashmap_access()
  72. : runtime_error{}
  73. {
  74. what_str = "bad_hashmap_access error has occured";
  75. }
  76. };
  77. class bad_alloc : public runtime_error{
  78. public:
  79. bad_alloc(const char* what)
  80. : runtime_error{what}
  81. {}
  82. bad_alloc()
  83. : runtime_error{}
  84. {
  85. what_str = "bad_alloc error has occured";
  86. }
  87. };
  88. class bad_functor : public runtime_error{
  89. public:
  90. bad_functor(const char* what)
  91. : runtime_error{what}
  92. {}
  93. bad_functor()
  94. : runtime_error{}
  95. {
  96. what_str = "bad_functor error has occured";
  97. }
  98. };
  99. }