My Project
AnnException.cpp
Go to the documentation of this file.
1 // This is an open source non-commercial project. Dear PVS-Studio, please check it.
2 // PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
3 
4 #include "AnnException.hpp"
5 #include "AnnLogger.hpp"
6 
7 using namespace std;
8 using namespace Annwvyn;
9 
10 ostringstream AnnPhysicsSetupParentError::outputFormater;
11 
12 AnnPhysicsSetupParentError::AnnPhysicsSetupParentError(AnnGameObject* origin) :
13  runtime_error { "Cannot setup physics for object " },
14  objectWithProblem { origin }
15 {
16  AnnDebug(Log::Important) << AnnPhysicsSetupParentError::what();
17 }
18 
19 const char* AnnPhysicsSetupParentError::what() const throw()
20 {
21  outputFormater.str("");
22 
23  outputFormater << runtime_error::what() << " : " << objectWithProblem->getName();
24 
26  {
27  outputFormater << " child of : " << objectWithProblem->getParent()->getName() << '\n';
28  outputFormater << "The parent with a physics body is : " << getParentWithBody()->getName();
29  }
30 
31  outputFormater << "\nSetting up physics of a child object with parent"
32  " break the parent/transform derivation because the Physics engine"
33  " move object in world position.";
34 
35  outputFormater << "\n Consider not parenting theses two object if you want them to be independent physics objects.";
36 
37  return outputFormater.str().c_str();
38 }
39 
41 
43 
45 {
46  if(start->getParent()->getBody()) return start->getParent().get();
47  return recurToBody(start->getParent().get());
48 }
49 
51  runtime_error { "Cannot setup physics for Object " },
52  objectWithProblem { origin }
53 {
54  AnnDebug(Log::Important) << AnnPhysicsSetupChildError::what();
55 }
56 
57 const char* AnnPhysicsSetupChildError::what() const throw()
58 {
59  ostringstream out;
60  out << runtime_error::what();
61  out << objectWithProblem->getName() << '\n';
62  out << "a child has a rigid body. Creating a body will mess up the system. consider not using parenting for theses objects";
63  return out.str().c_str();
64 }
65 
67  runtime_error("Invalid hand controller side")
68 {
69  AnnDebug(Log::Important) << AnnInvalidControllerSide::what();
70 }
71 
72 const char* AnnInvalidControllerSide::what() const throw()
73 {
74  ostringstream out;
75  out << runtime_error::what();
76  out << "AnnHandController object initialized without knowing the side. This should not happen.";
77  return out.str().c_str();
78 }
79 
81  runtime_error("Error : Trying to do an operation on a null GameObject")
82 {
83  AnnDebug(Log::Important) << AnnNullGameObjectError::what();
84 }
85 
86 const char* AnnNullGameObjectError::what() const throw()
87 {
88  ostringstream out;
89  out << runtime_error::what();
90  out << "Check what you're doing with your pointers...";
91  return out.str().c_str();
92 }
93 
94 AnnInitializationError::AnnInitializationError(int errorCode, const string& message) :
95  runtime_error("Error : " + to_string(errorCode) + " " + message)
96 {
97  AnnDebug(Log::Important) << AnnInitializationError::what();
98 }
99 
100 const char* AnnInitializationError::what() const throw()
101 {
102  ostringstream out;
103  out << runtime_error::what();
104  out << " AnnInitializationError thrown";
105  return out.str().c_str();
106 }
107 
109  std::runtime_error("Error : Cannot create a physics shape from arguments"),
110  objectName { objName }
111 {
112  AnnDebug(Log::Important) << AnnInvalidPhysicalShapeError::what();
113 }
114 
115 const char* AnnInvalidPhysicalShapeError::what() const throw()
116 {
117  ostringstream out;
118  out << runtime_error::what();
119  out << " AnnInvalidPhysicalShapeError thrown on object ";
120  out << objectName;
121  return out.str().c_str();
122 }
123 
125  std::runtime_error("Error : Cannot load level object"),
126  levelName { level },
127  objectName { obj }
128 {
129  AnnDebug(Log::Important) << AnnLevelLoadingError::what();
130 }
131 
132 const char* AnnLevelLoadingError::what() const throw()
133 {
134  ostringstream out;
135  out << runtime_error::what();
136  out << " AnnLevelLoadingError ";
137  out << levelName;
138  out << " Additional object informations : " << objectName;
139  return out.str().c_str();
140 }
const std::string objectName
AnnLevelLoadingError(const std::string &levelName, const std::string &objectName)
const char * what() const override
AnnPhysicsSetupChildError(AnnGameObject *origin)
const char * what() const override
std::string getName() const
Return the name of the object.
T to_string(T... args)
AnnInvalidPhysicalShapeError(const std::string &objectName)
static std::ostringstream outputFormater
static AnnGameObject * recurToBody(AnnGameObject *start)
std::shared_ptr< AnnGameObject > getParent() const
Get the parent Game Object.
Namespace containing the totality of Annwvyn components.
Definition: AnnGetter.cpp:8
An object that exist in the game. Graphically and Potentially Physically.
const char * what() const override
const char * what() const override
const char * what() const override
Pretty text to explain what's wrong.
Create a ostream to the Ogre logger.
bool hasParent() const
Return true if node is attached to the node owned by another AnnGameObject.
T str(T... args)
AnnInitializationError(int errorCode, const std::string &message)
Open an output stream to the engine log.
Definition: AnnLogger.hpp:23
const char * what() const override
AnnGameObject * getParentWithBody() const
AnnGameObject * getObject() const
const char * what() const override