Leviathan  0.8.0.0
Leviathan game engine
Exceptions.cpp
Go to the documentation of this file.
1 // ------------------------------------ //
2 #include "Exceptions.h"
3 #include "Logger.h"
4 #include "Define.h"
5 
6 using namespace Leviathan;
7 using namespace std;
8 // ------------------------------------ //
9 DLLEXPORT Leviathan::Exception::Exception(const char* description) noexcept : Message(description){
10 
11 }
12 
13 DLLEXPORT Leviathan::Exception::Exception(const std::string &description) noexcept :
14  Message(description)
15 {
16 
17 }
18 
19 DLLEXPORT Leviathan::Exception::Exception(const Exception &e) noexcept : Message(e.Message){
20 
21 }
22 // ------------------------------------ //
24 
25  Message = other.Message;
26  return *this;
27 }
28 // ------------------------------------ //
29 DLLEXPORT const char* Leviathan::Exception::what() const noexcept{
30 
31  return Message.c_str();
32 }
33 // ------------------------------------ //
34 #ifndef LEVIATHAN_UE_PLUGIN
35 DLLEXPORT void Leviathan::Exception::PrintToLog() const noexcept{
36 
37  Logger::Get()->Write(string("[EXCEPTION] ")+Message);
38 }
39 #endif
40 
41 DLLEXPORT void Leviathan::Exception::Print(LErrorReporter* errorreport) const noexcept {
42 
43  LEVIATHAN_ASSERT(errorreport != nullptr, "erroreport in Exception::Print may not be null");
44  errorreport->Write(string("[EXCEPTION] ") + Message);
45 }
46 
47 // ------------------------------------ //
48 DLLEXPORT Leviathan::InvalidAccess::InvalidAccess(const char* description) noexcept : Exception(description){
49 }
50 
51 DLLEXPORT Leviathan::InvalidAccess::InvalidAccess(const std::string &description) noexcept : Exception(description){
52 }
53 
54 DLLEXPORT Leviathan::InvalidArgument::InvalidArgument(const char* description) noexcept : Exception(description){
55 }
56 
57 DLLEXPORT Leviathan::InvalidArgument::InvalidArgument(const std::string &description) noexcept : Exception(description){
58 }
59 
60 DLLEXPORT Leviathan::InvalidState::InvalidState(const char* description) noexcept : Exception(description){
61 }
62 
63 DLLEXPORT Leviathan::InvalidState::InvalidState(const std::string &description) noexcept : Exception(description){
64 }
65 
66 DLLEXPORT Leviathan::InvalidType::InvalidType(const char* description) noexcept : Exception(description){
67 }
68 
69 DLLEXPORT Leviathan::InvalidType::InvalidType(const std::string &description) noexcept : Exception(description){
70 }
71 
72 DLLEXPORT Leviathan::NotFound::NotFound(const char* description) noexcept : Exception(description){
73 }
74 
75 DLLEXPORT Leviathan::NotFound::NotFound(const std::string &description) noexcept : Exception(description){
76 }
77 
78 DLLEXPORT Leviathan::NULLPtr::NULLPtr(const char* description) noexcept : Exception(description){
79 }
80 
81 DLLEXPORT Leviathan::NULLPtr::NULLPtr(const std::string &description) noexcept : Exception(description){
82 }
83 
84 
85 
DLLEXPORT void Write(const std::string &data) override
Definition: Logger.cpp:113
DLLEXPORT NULLPtr(const char *description) noexcept
Definition: Exceptions.cpp:78
DLLEXPORT Exception & operator=(const Exception &other) noexcept
Definition: Exceptions.cpp:23
STL namespace.
std::string Message
Definition: Exceptions.h:31
Base class for all exceptions thrown by Leviathan.
Definition: Exceptions.h:10
DLLEXPORT const char * what() const noexcept override
Definition: Exceptions.cpp:29
DLLEXPORT InvalidAccess(const char *description) noexcept
Definition: Exceptions.cpp:48
virtual DLLEXPORT void Print(LErrorReporter *errorreport) const noexcept
Definition: Exceptions.cpp:41
DLLEXPORT InvalidState(const char *description) noexcept
Definition: Exceptions.cpp:60
static DLLEXPORT Logger * Get()
Definition: Logger.cpp:106
DLLEXPORT InvalidType(const char *description) noexcept
Definition: Exceptions.cpp:66
#define DLLEXPORT
Definition: Include.h:115
DLLEXPORT Exception(const char *description) noexcept
Definition: Exceptions.cpp:9
The access mask controls which registered functions and classes a script sees.
Definition: GameModule.h:12
DLLEXPORT InvalidArgument(const char *description) noexcept
Definition: Exceptions.cpp:54
DLLEXPORT NotFound(const char *description) noexcept
Definition: Exceptions.cpp:72