MyGUI 3.4.3
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
11#include <utility>
12
13namespace MyGUI
14{
15
16 Exception::Exception(std::string _description, std::string _source, std::string _file, long _line) :
17 mDescription(std::move(_description)),
18 mSource(std::move(_source)),
19 mFile(std::move(_file)),
20 mLine(_line)
21 {
22 }
23
24 const std::string& Exception::getFullDescription() const
25 {
26 if (mFullDesc.empty())
27 {
28 if (mLine > 0)
29 {
31 "MyGUI EXCEPTION : ",
33 " in ",
34 mSource,
35 " at ",
36 mFile,
37 " (line ",
38 mLine,
39 ")");
40 }
41 else
42 {
43 mFullDesc = utility::toString("MyGUI EXCEPTION : ", mDescription, " in ", mSource);
44 }
45 }
46
47 return mFullDesc;
48 }
49
50 const std::string& Exception::getSource() const
51 {
52 return mSource;
53 }
54
55 const std::string& Exception::getFile() const
56 {
57 return mFile;
58 }
59
60 long Exception::getLine() const
61 {
62 return mLine;
63 }
64
65 const std::string& Exception::getDescription() const
66 {
67 return mDescription;
68 }
69
70 // Override std::exception::what
71 const char* Exception::what() const noexcept
72 {
73 return getFullDescription().c_str();
74 }
75
76} // namespace MyGUI
Exception(std::string _description, std::string _source, std::string _file, long _line)
std::string mFullDesc
virtual long getLine() const
std::string mSource
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
std::string toString(T _value)