comparison Framework/StoneException.h @ 1049:348866dd217c

removing classes OpenGLContextLostException and StoneOrthancException
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 10 Oct 2019 14:29:02 +0200
parents efc5b62b9539
children 5df50e0f0390
comparison
equal deleted inserted replaced
1048:f6be9412e42a 1049:348866dd217c
44 ErrorCode_WebGLContextLost, 44 ErrorCode_WebGLContextLost,
45 ErrorCode_Last 45 ErrorCode_Last
46 }; 46 };
47 47
48 48
49
50 class StoneException 49 class StoneException
51 { 50 {
52 protected: 51 protected:
53 OrthancStone::ErrorCode errorCode_; 52 OrthancStone::ErrorCode errorCode_;
54 53
66 } 65 }
67 66
68 virtual const char* What() const 67 virtual const char* What() const
69 { 68 {
70 return "TODO: EnumerationToString for StoneException"; 69 return "TODO: EnumerationToString for StoneException";
71 }
72 };
73
74 class OpenGLContextLostException : public StoneException
75 {
76 public:
77 explicit OpenGLContextLostException(void* context)
78 : StoneException(ErrorCode_WebGLContextLost)
79 , context_(context)
80 {
81 }
82 virtual const char* What() const
83 {
84 return "The OpenGL/WebGL context has been lost!";
85 }
86 void* context_;
87 };
88
89 // TODO - Is this still necessary?
90 class StoneOrthancException : public StoneException
91 {
92 protected:
93 Orthanc::OrthancException& orthancException_;
94
95 public:
96 explicit StoneOrthancException(Orthanc::OrthancException& orthancException) :
97 StoneException(ErrorCode_OrthancError),
98 orthancException_(orthancException)
99 {
100 }
101
102 Orthanc::ErrorCode GetOrthancErrorCode() const
103 {
104 return orthancException_.GetErrorCode();
105 }
106
107 virtual const char* What() const
108 {
109 return orthancException_.What();
110 }
111 };
112
113 // TODO - To be moved in "../Applications/"
114 class StoneApplicationException : public StoneException
115 {
116 protected:
117 int applicationErrorCode_;
118 mutable std::string errorMessage_;
119
120 public:
121 explicit StoneApplicationException(int applicationErrorCode) :
122 StoneException(ErrorCode_ApplicationException),
123 applicationErrorCode_(applicationErrorCode)
124 {
125 }
126
127 int GetApplicationErrorCode() const
128 {
129 return applicationErrorCode_;
130 }
131
132 virtual const char* What() const
133 {
134 if (errorMessage_.size() == 0)
135 errorMessage_ = boost::lexical_cast<std::string>(applicationErrorCode_);
136
137 return errorMessage_.c_str();
138 } 70 }
139 }; 71 };
140 } 72 }
141 73
142 // See https://isocpp.org/wiki/faq/misc-technical-issues#macros-with-multi-stmts 74 // See https://isocpp.org/wiki/faq/misc-technical-issues#macros-with-multi-stmts
163 95
164 96
165 97
166 98
167 99
168
169
170
171
172
173
174
175
176 /* 100 /*
177 Explanation: 101 Explanation:
178 102
179 ORTHANC_ASSERT(a) 103 ORTHANC_ASSERT(a)
180 ORTHANC_EXPAND(GET_ORTHANC_ASSERT(a, ORTHANC_ASSERT2, ORTHANC_ASSERT1, UNUSED)(a)) 104 ORTHANC_EXPAND(GET_ORTHANC_ASSERT(a, ORTHANC_ASSERT2, ORTHANC_ASSERT1, UNUSED)(a))