MyGUI: MyGUI_Exception.cpp Source File

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"
9#include "MyGUI_StringUtility.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 {
30 mFullDesc = utility::toString(
31 "MyGUI EXCEPTION : ",
32 mDescription,
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
MyGUI_Exception.h
MyGUI_Precompiled.h
MyGUI_StringUtility.h
MyGUI::Exception::Exception
Exception(std::string _description, std::string _source, std::string _file, long _line)
Definition MyGUI_Exception.cpp:16
MyGUI::Exception::mFullDesc
std::string mFullDesc
Definition MyGUI_Exception.h:45
MyGUI::Exception::getLine
virtual long getLine() const
Definition MyGUI_Exception.cpp:60
MyGUI::Exception::mSource
std::string mSource
Definition MyGUI_Exception.h:42
MyGUI::Exception::getSource
virtual const std::string & getSource() const
Definition MyGUI_Exception.cpp:50
MyGUI::Exception::what
const char * what() const noexcept override
Definition MyGUI_Exception.cpp:71
MyGUI::Exception::mDescription
std::string mDescription
Definition MyGUI_Exception.h:41
MyGUI::Exception::getFullDescription
virtual const std::string & getFullDescription() const
Definition MyGUI_Exception.cpp:24
MyGUI::Exception::getFile
virtual const std::string & getFile() const
Definition MyGUI_Exception.cpp:55
MyGUI::Exception::getDescription
virtual const std::string & getDescription() const
Definition MyGUI_Exception.cpp:65
MyGUI::Exception::mFile
std::string mFile
Definition MyGUI_Exception.h:43
MyGUI::Exception::mLine
long mLine
Definition MyGUI_Exception.h:44
MyGUI::utility::toString
std::string toString(T _value)
Definition MyGUI_StringUtility.h:26
MyGUI
Definition MyGUI_ActionController.h:15