Spinning Topp Logo BlackTopp Studios
inc
exception.cpp
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 
41 #ifndef _exception_cpp
42 #define _exception_cpp
43 
44 #include "exception.h"
45 #include "stringtool.h"
46 #include "entresol.h"
47 
48 #ifdef MEZZDEBUG
49 #include <iostream>
50 #endif
51 
52 namespace Mezzanine
53 {
55  const Mezzanine::String& JavaTypeName,
56  const String& Message,
57  const String& SrcFunction,
58  const String& SrcFile,
59  const Whole& FileLine)
60  : ErrorMessage(Message),
61  ExceptionJavaTypeName(JavaTypeName),
62  ExceptionTypeName(TypeName),
63  Function(SrcFunction),
64  File(SrcFile),
65  Line(FileLine)
66  {
67  if( Entresol::SingletonValid() ) {
69  }else{
70  #ifdef MEZZDEBUG
71  std::cerr << GetCompleteMessage();
72  #endif
73  }
74  }
75 
77  { }
78 
79  ///////////////////////////////////////////////////////////////////////////////
80  // Error Information
82  { return ExceptionTypeName; }
83 
85  { return ExceptionJavaTypeName; }
86 
88  { return Function; }
89 
91  { return File; }
92 
93  const Whole& ExceptionBase::GetLine() const throw()
94  { return Line; }
95 
97  {
98  try
99  {
100  StringStream ErrorStream;
101  ErrorStream << "MEZZANINE EXCEPTION(" << ExceptionTypeName << "): "
102  << ErrorMessage << " In " << Function << ". " << "At line "
103  << (Line?StringTools::ConvertToString(Line):"Unknown") << " of "
104  << File << ".";
105  return ErrorStream.str();
106  } catch(...) {
107  return "Error details unknown erro caught while generating exception message. :(";
108  }
109  }
110 
111  ///////////////////////////////////////////////////////////////////////////////
112  // Error Messages
113  const char* ExceptionBase::what() const throw()
114  { return GetCompleteMessage().c_str(); }
115 }//Mezzanine
116 
117 #endif // \exception_cpp
const Mezzanine::String & GetFile() const
Gets the file of the exception.
Definition: exception.cpp:90
const Mezzanine::Whole & GetLine() const
Gets the line number of the exception.
Definition: exception.cpp:93
String ConvertToString(const Vector2 &ToConvert)
Converts a Vector2 into a string.
Definition: stringtool.cpp:291
void _Log(const T &Message)
Runtime event and message logging.
Definition: entresol.h:686
Mezzanine::String GetCompleteMessage() const
Constructs the complete message from all the information provided about the exception.
Definition: exception.cpp:96
ExceptionBase(const Mezzanine::String &TypeName, const Mezzanine::String &JavaTypeName, const Mezzanine::String &Message, const Mezzanine::String &SrcFunction, const Mezzanine::String &SrcFile, const Mezzanine::Whole &FileLine)
Simple Constructor.
Definition: exception.cpp:54
This implements the exception hiearchy for Mezzanine.
std::stringstream StringStream
A Datatype used for streaming operations with strings.
Definition: datatypes.h:176
const Mezzanine::String & GetFunction() const
Gets the function of the exception.
Definition: exception.cpp:87
const Mezzanine::String & GetExceptionTypeName() const
Gets the name of the exception type.
Definition: exception.cpp:81
static Boole SingletonValid()
Checks to see if the singleton pointer is valid.
Definition: singleton.h:110
static Entresol * GetSingletonPtr()
Fetches a pointer to the singleton.
Definition: singleton.h:97
const String ConstString
A Datatype used to a series of imutable characters.
Definition: datatypes.h:165
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Definition: datatypes.h:151
const Mezzanine::String & GetExceptionJavaTypeName() const
Gets the name of the exception type.
Definition: exception.cpp:84
virtual const char * what() const
Retrieves the error message.
Definition: exception.cpp:113
virtual ~ExceptionBase()
Class destructor.
Definition: exception.cpp:76
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159