MyGUI 3.4.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"
10
11namespace 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 {
34 mSource = _rhs.mSource;
35 mFile = _rhs.mFile;
36 mLine = _rhs.mLine;
37 mFullDesc = _rhs.mFullDesc;
38 return *this;
39 }
40
41 const std::string& Exception::getFullDescription() const
42 {
43 if (mFullDesc.empty())
44 {
45 if ( mLine > 0 )
46 {
47 mFullDesc = utility::toString("MyGUI EXCEPTION : ", mDescription, " in ", mSource, " at ", mFile, " (line ", mLine, ")");
48 }
49 else
50 {
51 mFullDesc = utility::toString("MyGUI EXCEPTION : ", mDescription, " in ", mSource);
52 }
53 }
54
55 return mFullDesc;
56 }
57
58 const std::string& Exception::getSource() const
59 {
60 return mSource;
61 }
62
63 const std::string& Exception::getFile() const
64 {
65 return mFile;
66 }
67
68 long Exception::getLine() const
69 {
70 return mLine;
71 }
72
73 const std::string& Exception::getDescription() const
74 {
75 return mDescription;
76 }
77
78 // Override std::exception::what
79 const char* Exception::what() const noexcept
80 {
81 return getFullDescription().c_str();
82 }
83
84} // namespace MyGUI
std::string mFullDesc
virtual long getLine() const
std::string mSource
Exception(const std::string &_description, const std::string &_source, const char *_file, long _line)
virtual const std::string & getSource() const
const char * what() const noexcept override
std::string mDescription
virtual const std::string & getFullDescription() const
virtual const std::string & getFile() const
virtual const std::string & getDescription() const
Exception & operator=(const Exception &_rhs)
std::string mFile
std::string toString(T p)