MyGUI  3.2.1
MyGUI_Exception.cpp
Go to the documentation of this file.
1 /*
2  * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3  * Distributed under the MIT License
4  * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5  */
6 
7 #include "MyGUI_Precompiled.h"
8 #include "MyGUI_Exception.h"
9 #include "MyGUI_StringUtility.h"
10 
11 namespace MyGUI
12 {
13 
14  Exception::Exception(const std::string& _description, const std::string& _source, const char* _file, long _line ) :
15  mDescription(_description),
16  mSource(_source),
17  mFile(_file),
18  mLine(_line)
19  {
20  }
21 
23  mDescription(_rhs.mDescription),
24  mSource(_rhs.mSource),
25  mFile(_rhs.mFile),
26  mLine(_rhs.mLine),
27  mFullDesc(_rhs.mFullDesc)
28  {
29  }
30 
32  {
33  }
34 
36  {
38  mSource = _rhs.mSource;
39  mFile = _rhs.mFile;
40  mLine = _rhs.mLine;
41  mFullDesc = _rhs.mFullDesc;
42  return *this;
43  }
44 
45  const std::string& Exception::getFullDescription() const
46  {
47  if (mFullDesc.empty())
48  {
49  if ( mLine > 0 )
50  {
51  mFullDesc = utility::toString("MyGUI EXCEPTION : ", mDescription, " in ", mSource, " at ", mFile, " (line ", mLine, ")");
52  }
53  else
54  {
55  mFullDesc = utility::toString("MyGUI EXCEPTION : ", mDescription, " in ", mSource);
56  }
57  }
58 
59  return mFullDesc;
60  }
61 
62  const std::string& Exception::getSource() const
63  {
64  return mSource;
65  }
66 
67  const std::string& Exception::getFile() const
68  {
69  return mFile;
70  }
71 
72  long Exception::getLine() const
73  {
74  return mLine;
75  }
76 
77  const std::string& Exception::getDescription() const
78  {
79  return mDescription;
80  }
81 
82  // Override std::exception::what
83  const char* Exception::what() const throw()
84  {
85  return getFullDescription().c_str();
86  }
87 
88 } // namespace MyGUI