Lugdunum  0.1.0
Exception.cpp
Go to the documentation of this file.
2 #include <sstream>
3 
4 lug::System::Exception::Exception(const char* typeName, const std::string& description, const char* file, const char* function, uint32_t line)
5  : _typeName{typeName}, _description{description}, _file{file}, _function{function}, _line{line} {}
6 
7 const std::string& lug::System::Exception::getTypeName() const {
8  return _typeName;
9 }
10 
11 const std::string& lug::System::Exception::getDescription() const {
12  return _description;
13 }
14 
15 const std::string& lug::System::Exception::getFile() const {
16  return _file;
17 }
18 
19 const std::string& lug::System::Exception::getFunction() const {
20  return _function;
21 }
22 
24  return _line;
25 }
26 
27 const char* lug::System::Exception::what() const noexcept {
28  std::stringstream msg;
29 
30  msg << _typeName << ": " << _description << std::endl;
31  msg << "In " << _file;
32  msg << " at `" << _function << "` line " << _line;
33 
34  _fullDesc = msg.str();
35  return _fullDesc.c_str();
36 }
uint32_t getLine() const
Line getter.
Definition: Exception.cpp:23
std::string _typeName
Definition: Exception.hpp:66
const char * what() const noexcept override
Return the full formated exception.
Definition: Exception.cpp:27
const std::string & getFunction() const
Function getter.
Definition: Exception.cpp:19
const std::string & getFile() const
File getter.
Definition: Exception.cpp:15
const std::string & getDescription() const
Description getter.
Definition: Exception.cpp:11
std::string _description
Definition: Exception.hpp:67
const std::string & getTypeName() const
TypeName getter.
Definition: Exception.cpp:7
std::string _function
Definition: Exception.hpp:69
std::string _fullDesc
Definition: Exception.hpp:72
Exception(const char *typeName, const std::string &description, const char *file, const char *function, uint32_t line)
Exception constructor.
Definition: Exception.cpp:4