Lugdunum  0.1.0
Exception.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <exception>
4 #include <cstdint>
5 #include <string>
6 #include <lug/System/Export.hpp>
7 #include <lug/System/Utils.hpp>
8 
9 namespace lug {
10 namespace System {
11 
12 class LUG_SYSTEM_API Exception: public std::exception {
13 public:
22  Exception(const char *typeName, const std::string &description, const char* file, const char* function, uint32_t line);
23  Exception(Exception&& other) = default;
24  Exception(const Exception& other) = default;
25  Exception& operator=(const Exception& other) = default;
26  Exception& operator=(Exception&& other) = default;
27  virtual ~Exception() throw() {}
28 
33  const std::string& getTypeName() const;
34 
39  const std::string& getDescription() const;
40 
45  const std::string& getFile() const;
46 
51  const std::string& getFunction() const;
52 
57  uint32_t getLine() const;
58 
63  const char* what() const noexcept override;
64 
65 private:
66  std::string _typeName;
67  std::string _description;
68  std::string _file;
69  std::string _function;
70  uint32_t _line;
71 
72  mutable std::string _fullDesc;
73 };
74 
76 public:
77  NotImplementedException(const std::string &description, const char* file, const char* function, uint32_t line)
78  : Exception{"NotImplementedException", description, file, function, line} {}
79 };
80 
81 
83 public:
84  FileNotFoundException(const std::string &description, const char* file, const char* function, uint32_t line)
85  : Exception{"FileNotFoundException", description, file, function, line} {}
86 };
87 
88 
90 public:
91  IOException(const std::string &description, const char* file, const char* function, uint32_t line)
92  : Exception{"IOException", description, file, function, line} {}
93 };
94 
95 
97 public:
98  InvalidParametersException(const std::string &description, const char* file, const char* function, uint32_t line)
99  : Exception{"InvalidParametersException", description, file, function, line} {}
100 };
101 
102 
104 public:
105  InternalErrorException(const std::string &description, const char* file, const char* function, uint32_t line)
106  : Exception{"InternalErrorException", description, file, function, line} {}
107 };
108 
109 
111 public:
112  RendererException(const std::string &description, const char* file, const char* function, uint32_t line)
113  : Exception{"RendererException", description, file, function, line} {}
114 };
115 
116 
118 public:
119  WindowException(const std::string &description, const char* file, const char* function, uint32_t line)
120  : Exception{"WindowException", description, file, function, line} {}
121 };
122 
123 
124 #define LUG_EXCEPT(type, desc)\
125 do {\
126  throw ::lug::System::type(desc, __FILE__, LUG_SYSTEM_FUNCTION_NAME, __LINE__);\
127 } while (0)
128 
129 } // System
130 } // lug
#define LUG_SYSTEM_API
Definition: Export.hpp:11
FileNotFoundException(const std::string &description, const char *file, const char *function, uint32_t line)
Definition: Exception.hpp:84
std::string _typeName
Definition: Exception.hpp:66
NotImplementedException(const std::string &description, const char *file, const char *function, uint32_t line)
Definition: Exception.hpp:77
WindowException(const std::string &description, const char *file, const char *function, uint32_t line)
Definition: Exception.hpp:119
IOException(const std::string &description, const char *file, const char *function, uint32_t line)
Definition: Exception.hpp:91
RendererException(const std::string &description, const char *file, const char *function, uint32_t line)
Definition: Exception.hpp:112
std::string _description
Definition: Exception.hpp:67
std::string _function
Definition: Exception.hpp:69
InvalidParametersException(const std::string &description, const char *file, const char *function, uint32_t line)
Definition: Exception.hpp:98
std::string _fullDesc
Definition: Exception.hpp:72
InternalErrorException(const std::string &description, const char *file, const char *function, uint32_t line)
Definition: Exception.hpp:105