CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
exceptions.h
1
3#pragma once
4
5#include <string>
6#include <memory>
7#include "system/string.h"
8#include "system/exception.h"
9#include "system/nullable.h"
10
11#ifndef E_FAIL__
13#define E_FAIL__ 0x80004005
14#endif
15
16
17//EXCEPTION_NAMESPACE(Parent::Name::Space, Class) or EXCEPTION_NAMESPACE(, System) if there is no parent
20#define EXCEPTION_NAMESPACE(pns, ns) namespace ns\
21{\
22 \
23 inline const System::String& CURRENT_NAMESPACE()\
24 {\
25 static const System::String name = System::String(ASPOSE_T(#pns)).IsEmpty() ? System::String(ASPOSE_T(#ns)) : System::String(ASPOSE_T(#pns) "::" ASPOSE_T(#ns));\
26 return name;\
27 }\
28 \
29}\
30namespace ns
31
32//Reflection helpers similar ones from reflection.h
34#define __ThisTypeInfo_Runtime_NameSpace(thisType) \
35 struct ThisTypeInfo : System::TypeInfoPtr { \
36 ThisTypeInfo() : System::TypeInfoPtr(thisType) {
37
38// baseTypes: System::BaseTypesInfo<TypeA, TypeB, TypeC>
40#define RTTI_INFO_NAMESPACE(thisType, baseTypes) \
41 __RTTI_INFO_METHODS(thisType, baseTypes) \
42 __ThisTypeInfo_Runtime_NameSpace((CURRENT_NAMESPACE() + u"::" + ASPOSE_T(#thisType))) \
43 RTTI_INFO_END()
44
45//Exception related macros
48#define DECLARE_INHERITED_EXCEPTION(name, parent) \
49class Details_##name; \
50using name = System::ExceptionWrapper<Details_##name>; \
51class ASPOSECPP_SHARED_CLASS Details_##name : public parent { \
52 friend class System::ExceptionWrapperHelper; \
53 template <typename T> friend class System::ExceptionWrapper; \
54 RTTI_INFO_NAMESPACE(name, System::BaseTypesInfo<parent>) \
55protected: \
56 \
57 using BaseType = parent; \
58 \
59 Details_##name() : parent() {} \
60 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(), CODEPORTING_ARGS()); \
61 \
62 \
63 Details_##name(const System::String &message) : parent(message) {} \
64 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(const System::String &message), CODEPORTING_ARGS(message)); \
65 \
66 \
67 \
68 Details_##name(const System::String &message, const System::ExceptionWrapper<System::Details_Exception>& innerException) : parent(message, innerException) {} \
69 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, \
70 CODEPORTING_ARGS(const System::String &message, const System::ExceptionWrapper<System::Details_Exception>& innerException), \
71 CODEPORTING_ARGS(message, innerException) \
72 ); \
73 \
74 \
75 \
76 Details_##name(const System::SharedPtr<System::Runtime::Serialization::SerializationInfo>& info, System::Runtime::Serialization::StreamingContext context) : parent(info, context) {} \
77 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, \
78 CODEPORTING_ARGS(const System::SharedPtr<System::Runtime::Serialization::SerializationInfo>& info, System::Runtime::Serialization::StreamingContext context), \
79 CODEPORTING_ARGS(info, context) \
80 ); \
81 \
82 [[noreturn]] void DoThrow(const System::ExceptionPtr& self) const override { throw System::ExceptionWrapper<Details_##name>(self); } \
83};
84
87#define DECLARE_INHERITED_EXCEPTION_MSG(name, parent) \
88class Details_##name; \
89using name = System::ExceptionWrapper<Details_##name>; \
90class ASPOSECPP_SHARED_CLASS Details_##name : public parent { \
91 friend class System::ExceptionWrapperHelper; \
92 template <typename T> friend class System::ExceptionWrapper; \
93 RTTI_INFO_NAMESPACE(name, System::BaseTypesInfo<parent>) \
94protected: \
95 \
96 using BaseType = parent; \
97 \
98 Details_##name() : parent(MessageDefault()) {} \
99 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(), CODEPORTING_ARGS()); \
100 \
101 \
102 Details_##name(const System::String &message) : parent(DefaultMessageIfNull(message)) {} \
103 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(const System::String &message), CODEPORTING_ARGS(message)); \
104 \
105 \
106 \
107 Details_##name(const System::String &message, const System::Exception& innerException) : parent(DefaultMessageIfNull(message), innerException) {} \
108 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, \
109 CODEPORTING_ARGS(const System::String &message, const System::Exception& innerException), \
110 CODEPORTING_ARGS(message, innerException) \
111 ); \
112 \
113 \
114 \
115 Details_##name(const System::SharedPtr<System::Runtime::Serialization::SerializationInfo>& info, System::Runtime::Serialization::StreamingContext context) : parent(info, context) {} \
116 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, \
117 CODEPORTING_ARGS(const System::SharedPtr<System::Runtime::Serialization::SerializationInfo>& info, System::Runtime::Serialization::StreamingContext context), \
118 CODEPORTING_ARGS(info, context) \
119 ); \
120 \
121 [[noreturn]] void DoThrow(const System::ExceptionPtr& self) const override { throw System::ExceptionWrapper<Details_##name>(self); } \
122private: \
123 \
124 \
125 ASPOSECPP_SHARED_API static const String& MessageDefault(); \
126 \
127 \
128 \
129 ASPOSECPP_SHARED_API static const String& DefaultMessageIfNull(const String& message); \
130};
131
135#define DECLARE_INHERITED_EXCEPTION_MSG2(name, parent) \
136class Details_##name; \
137using name = System::ExceptionWrapper<Details_##name>; \
138class ASPOSECPP_SHARED_CLASS Details_##name : public parent { \
139 friend class System::ExceptionWrapperHelper; \
140 template <typename T> friend class System::ExceptionWrapper; \
141 RTTI_INFO_NAMESPACE(name, System::BaseTypesInfo<parent>) \
142protected: \
143 \
144 using BaseType = parent; \
145 \
146 Details_##name() : parent(MessageDefault()) {} \
147 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(), CODEPORTING_ARGS()); \
148 \
149 \
150 Details_##name(const System::String &message) : parent(DefaultMessageIfNull(message)) {} \
151 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(const System::String &message), CODEPORTING_ARGS(message)); \
152 \
153 \
154 \
155 Details_##name(const System::String &message, const System::Exception& innerException) \
156 : parent(DefaultMessageIfNull(message), innerException) {} \
157 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, \
158 CODEPORTING_ARGS(const System::String &message, const System::Exception& innerException), \
159 CODEPORTING_ARGS(message, innerException) \
160 ); \
161 \
162 [[noreturn]] void DoThrow(const System::ExceptionPtr& self) const override { throw System::ExceptionWrapper<Details_##name>(self); } \
163private: \
164 \
165 \
166 ASPOSECPP_SHARED_API static const String& MessageDefault(); \
167 \
168 \
169 \
170 ASPOSECPP_SHARED_API static const String& DefaultMessageIfNull(const String& message); \
171};
172
174#define DECLARE_INHERITED_EXCEPTION_WITH_EXTRA_CODE(name, parent, code) \
175class Details_##name; \
176using name = System::ExceptionWrapper<Details_##name>; \
177class ASPOSECPP_SHARED_CLASS Details_##name : public parent { \
178 friend class System::ExceptionWrapperHelper; \
179 template <typename T> friend class System::ExceptionWrapper; \
180 RTTI_INFO_NAMESPACE(name, System::BaseTypesInfo<parent>) \
181public: \
182 \
183 \
184 int get_##code() { return m_##code; } \
185protected: \
186 \
187 using BaseType = parent; \
188 \
189 Details_##name() : parent() {} \
190 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(), CODEPORTING_ARGS()); \
191 \
192 \
193 Details_##name(int code) : parent(u""), m_##code(code) {} \
194 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(int code), CODEPORTING_ARGS(code)); \
195 \
196 \
197 Details_##name(const System::String &message) : parent(message) {} \
198 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(const System::String &message), CODEPORTING_ARGS(message)); \
199 \
200 \
201 \
202 Details_##name(int code, const System::String &message) : parent(message), m_##code(code) {} \
203 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(int code, const System::String &message), CODEPORTING_ARGS(code, message)); \
204 \
205 \
206 \
207 Details_##name(const System::String &message, const System::Exception& innerException) : parent(message, innerException) {} \
208 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(const System::String &message, const System::Exception& innerException), CODEPORTING_ARGS(message, innerException)); \
209 \
210 \
211 \
212 Details_##name(const System::SharedPtr<System::Runtime::Serialization::SerializationInfo>& info, System::Runtime::Serialization::StreamingContext context) : parent(info, context) {} \
213 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, \
214 CODEPORTING_ARGS(const System::SharedPtr<System::Runtime::Serialization::SerializationInfo>& info, System::Runtime::Serialization::StreamingContext context), \
215 CODEPORTING_ARGS(info, context) \
216 ); \
217 \
218 [[noreturn]] void DoThrow(const System::ExceptionPtr& self) const override { throw System::ExceptionWrapper<Details_##name>(self); } \
219 \
220 \
221 virtual String ExtraDescription() const override { return String::FromUtf8(std::to_string(m_##code)); } \
222 \
223 int m_##code = E_FAIL__; \
224};
225
229#define DECLARE_INHERITED_EXCEPTION_MSG_AND_EXTRA_MEMBER(name, parent, member) \
230class Details_##name; \
231using name = System::ExceptionWrapper<Details_##name>; \
232class ASPOSECPP_SHARED_CLASS Details_##name : public parent { \
233 friend class System::ExceptionWrapperHelper; \
234 template <typename T> friend class System::ExceptionWrapper; \
235 RTTI_INFO_NAMESPACE(name, System::BaseTypesInfo<parent>) \
236public: \
237 \
238 \
239 String get_##member() { return m_##member; } \
240protected: \
241 \
242 using BaseType = parent; \
243 \
244 Details_##name() : parent(MessageDefault()) {} \
245 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(), CODEPORTING_ARGS()); \
246 \
247 \
248 Details_##name(const System::String &message) : parent(DefaultMessageIfNull(message)) {} \
249 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(const System::String &message), CODEPORTING_ARGS(message)); \
250 \
251 \
252 \
253 Details_##name(const System::String &message, const System::Exception& innerException) : parent(DefaultMessageIfNull(message), innerException) {} \
254 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, \
255 CODEPORTING_ARGS(const System::String &message, const System::Exception& innerException), \
256 CODEPORTING_ARGS(message, innerException) \
257 ); \
258 \
259 \
260 \
261 Details_##name(const System::String &message, const System::String & member) : parent(DefaultMessageIfNull(message)), m_##member(member) {} \
262 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(const System::String &message, const System::String & member), CODEPORTING_ARGS(message, member)); \
263 \
264 \
265 \
266 \
267 Details_##name(const System::String &message, const System::String & member, const System::Exception& innerException) \
268 : parent(DefaultMessageIfNull(message), innerException), m_##member(member) {} \
269 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, \
270 CODEPORTING_ARGS(const System::String &message, const System::String & member, const System::Exception& innerException), \
271 CODEPORTING_ARGS(message, member, innerException) \
272 ); \
273 \
274 \
275 \
276 Details_##name(const System::SharedPtr<System::Runtime::Serialization::SerializationInfo>& info, System::Runtime::Serialization::StreamingContext context) : parent(info, context) {} \
277 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, \
278 CODEPORTING_ARGS(const System::SharedPtr<System::Runtime::Serialization::SerializationInfo>& info, System::Runtime::Serialization::StreamingContext context), \
279 CODEPORTING_ARGS(info, context) \
280 ); \
281 \
282 [[noreturn]] void DoThrow(const System::ExceptionPtr& self) const override { throw System::ExceptionWrapper<Details_##name>(self); } \
283 \
284 \
285 virtual String ExtraDescription() const override { return m_##member; } \
286 \
287 String m_##member; \
288private: \
289 \
290 \
291 ASPOSECPP_SHARED_API static const String& MessageDefault(); \
292 \
293 \
294 \
295 ASPOSECPP_SHARED_API static const String& DefaultMessageIfNull(const String& message); \
296};
297
302#define DECLARE_INHERITED_EXCEPTION_MSG_AND_EXTRA_MEMBER2(name, parent, member) \
303class Details_##name; \
304using name = System::ExceptionWrapper<Details_##name>; \
305class ASPOSECPP_SHARED_CLASS Details_##name : public parent { \
306 friend class System::ExceptionWrapperHelper; \
307 template <typename T> friend class System::ExceptionWrapper; \
308 RTTI_INFO_NAMESPACE(name, System::BaseTypesInfo<parent>) \
309public: \
310 \
311 \
312 String get_##member() { return m_##member; } \
313protected: \
314 \
315 using BaseType = parent; \
316 \
317 Details_##name() : parent(MessageDefault()) {} \
318 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(), CODEPORTING_ARGS()); \
319 \
320 \
321 Details_##name(const System::String &member) : parent(MessageDefault()), m_##member(member) {} \
322 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(const System::String &member), CODEPORTING_ARGS(member)); \
323 \
324 \
325 \
326 Details_##name(const System::String &message, const System::Exception& innerException) : parent(DefaultMessageIfNull(message), innerException) {} \
327 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, \
328 CODEPORTING_ARGS(const System::String &message, const System::Exception& innerException), \
329 CODEPORTING_ARGS(message, innerException) \
330 ); \
331 \
332 \
333 \
334 Details_##name(const System::String &member, const System::String &message) : parent(DefaultMessageIfNull(message)), m_##member(member) {} \
335 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(const System::String &member, const System::String &message), CODEPORTING_ARGS(member, message)); \
336 \
337 \
338 \
339 template<typename T> Details_##name(const System::String& member, const T&, const System::String& message) : parent(DefaultMessageIfNull(message)), m_##member(member) {} \
340 template<typename T> MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(const System::String& member, const T& t, const System::String& message), CODEPORTING_ARGS(member, t, message)); \
341 \
342 \
343 \
344 Details_##name(const System::SharedPtr<System::Runtime::Serialization::SerializationInfo>& info, System::Runtime::Serialization::StreamingContext context) : parent(info, context) {} \
345 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, \
346 CODEPORTING_ARGS(const System::SharedPtr<System::Runtime::Serialization::SerializationInfo>& info, System::Runtime::Serialization::StreamingContext context), \
347 CODEPORTING_ARGS(info, context) \
348 ); \
349 \
350 [[noreturn]] void DoThrow(const System::ExceptionPtr& self) const override { throw System::ExceptionWrapper<Details_##name>(self); } \
351 \
352 \
353 virtual String ExtraDescription() const override { return m_##member; } \
354 \
355 String m_##member; \
356private: \
357 \
358 \
359 ASPOSECPP_SHARED_API static const String& MessageDefault(); \
360 \
361 \
362 \
363 ASPOSECPP_SHARED_API static const String& DefaultMessageIfNull(const String& message); \
364};
365
370#define DECLARE_INHERITED_EXCEPTION_MSG_AND_EXTRA_NON_NULL_MEMBER(name, parent, member) \
371class Details_##name; \
372using name = System::ExceptionWrapper<Details_##name>; \
373class ASPOSECPP_SHARED_CLASS Details_##name : public parent { \
374 friend class System::ExceptionWrapperHelper; \
375 template <typename T> friend class System::ExceptionWrapper; \
376 RTTI_INFO_NAMESPACE(name, System::BaseTypesInfo<parent>) \
377public: \
378 \
379 \
380 String get_##member() { return m_##member; } \
381protected: \
382 \
383 using BaseType = parent; \
384 \
385 Details_##name() : parent(MessageDefault()), m_##member(System::String::Empty) {} \
386 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(), CODEPORTING_ARGS()); \
387 \
388 \
389 Details_##name(const System::String &member) : parent(MessageDefault()), m_##member(EmptyStringIfNull(member)) {} \
390 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(const System::String &member), CODEPORTING_ARGS(member)); \
391 \
392 \
393 \
394 Details_##name(const System::String &message, const System::Exception& innerException) \
395 : parent(DefaultMessageIfNull(message), innerException), m_##member(System::String::Empty) {} \
396 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, \
397 CODEPORTING_ARGS(const System::String &message, const System::Exception& innerException), \
398 CODEPORTING_ARGS(message, innerException) \
399 ); \
400 \
401 \
402 \
403 Details_##name(const System::String &member, const System::String &message) : parent(DefaultMessageIfNull(message)), m_##member(EmptyStringIfNull(member)) {} \
404 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, \
405 CODEPORTING_ARGS(const System::String &member, const System::String &message), \
406 CODEPORTING_ARGS(member, message) \
407 ); \
408 \
409 \
410 \
411 template<typename T> Details_##name(const System::String& member, const T&, const System::String& message) : parent(DefaultMessageIfNull(message)), m_##member(EmptyStringIfNull(member)) {} \
412 template<typename T> MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(const System::String& member, const T& t, const System::String& message), CODEPORTING_ARGS(member, t, message)); \
413 \
414 \
415 \
416 Details_##name(const System::SharedPtr<System::Runtime::Serialization::SerializationInfo>& info, System::Runtime::Serialization::StreamingContext context) : parent(info, context) {} \
417 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, \
418 CODEPORTING_ARGS(const System::SharedPtr<System::Runtime::Serialization::SerializationInfo>& info, System::Runtime::Serialization::StreamingContext context), \
419 CODEPORTING_ARGS(info, context) \
420 ); \
421 \
422 [[noreturn]] void DoThrow(const System::ExceptionPtr& self) const override { throw System::ExceptionWrapper<Details_##name>(self); } \
423 \
424 \
425 virtual String ExtraDescription() const override { return m_##member; } \
426 \
427 String m_##member; \
428private: \
429 \
430 \
431 ASPOSECPP_SHARED_API static const String& MessageDefault(); \
432 \
433 \
434 \
435 ASPOSECPP_SHARED_API static const String& DefaultMessageIfNull(const String& message); \
436 \
437 \
438 \
439 ASPOSECPP_SHARED_API static const String& EmptyStringIfNull(const String& member); \
440};
441
446#define DECLARE_INHERITED_EXCEPTION_MSG_AND_SUBSTITUTE_NON_NULL_MEMBER(name, parent, member) \
447class Details_##name; \
448using name = System::ExceptionWrapper<Details_##name>; \
449class ASPOSECPP_SHARED_CLASS Details_##name : public parent { \
450 friend class System::ExceptionWrapperHelper; \
451 template <typename T> friend class System::ExceptionWrapper; \
452 RTTI_INFO_NAMESPACE(name, System::BaseTypesInfo<parent>) \
453public: \
454 \
455 \
456 String get_##member() { return m_##member; } \
457protected: \
458 \
459 using BaseType = parent; \
460 \
461 \
462 \
463 Details_##name(const System::String &member, const System::Exception& innerException) \
464 : parent(DefaultMessage(member), innerException), m_##member(EmptyStringIfNull(member)) {} \
465 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, \
466 CODEPORTING_ARGS(const System::String &member, const System::Exception& innerException), \
467 CODEPORTING_ARGS(member, innerException) \
468 ); \
469 \
470 \
471 \
472 Details_##name(const System::SharedPtr<System::Runtime::Serialization::SerializationInfo>& info, System::Runtime::Serialization::StreamingContext context) : parent(info, context) {} \
473 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, \
474 CODEPORTING_ARGS(const System::SharedPtr<System::Runtime::Serialization::SerializationInfo>& info, System::Runtime::Serialization::StreamingContext context), \
475 CODEPORTING_ARGS(info, context) \
476 ); \
477 \
478 [[noreturn]] void DoThrow(const System::ExceptionPtr& self) const override { throw System::ExceptionWrapper<Details_##name>(self); } \
479 \
480 \
481 virtual String ExtraDescription() const override { return m_##member; } \
482 \
483 String m_##member; \
484private: \
485 \
486 \
487 \
488 ASPOSECPP_SHARED_API static String DefaultMessage(const String& parameter); \
489 \
490 \
491 \
492 \
493 ASPOSECPP_SHARED_API static String DefaultMessageIfNull(const String& message, const String& parameter); \
494 \
495 \
496 \
497 ASPOSECPP_SHARED_API static const String& EmptyStringIfNull(const String& member); \
498};
499
501#define DECLARE_EXTERNAL_EXCEPTION(name, parent, code) \
502class Details_##name; \
503using name = System::ExceptionWrapper<Details_##name>; \
504class ASPOSECPP_SHARED_CLASS Details_##name : public parent { \
505 friend class System::ExceptionWrapperHelper; \
506 template <typename T> friend class System::ExceptionWrapper; \
507 RTTI_INFO_NAMESPACE(name, System::BaseTypesInfo<parent>) \
508public: \
509 \
510 \
511 int get_##code() { return m_##code; } \
512protected: \
513 \
514 using BaseType = parent; \
515 \
516 Details_##name() : parent() {} \
517 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(), CODEPORTING_ARGS()); \
518 \
519 \
520 Details_##name(const System::String &message) : parent(message) {} \
521 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(const System::String &message), CODEPORTING_ARGS(message)); \
522 \
523 \
524 \
525 Details_##name(const System::String &message, int code) : parent(message), m_##code(code) {} \
526 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(const System::String &message, int code), CODEPORTING_ARGS(message, code)); \
527 \
528 \
529 \
530 Details_##name(const System::String &message, const System::ExceptionWrapper<System::Details_Exception>& innerException) : parent(message, innerException) {} \
531 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(const System::String &message, const System::ExceptionWrapper<System::Details_Exception>& innerException), CODEPORTING_ARGS(message, innerException)); \
532 \
533 \
534 \
535 Details_##name(const System::SharedPtr<System::Runtime::Serialization::SerializationInfo>& info, System::Runtime::Serialization::StreamingContext context) : parent(info, context) {} \
536 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(const System::SharedPtr<System::Runtime::Serialization::SerializationInfo>& info, System::Runtime::Serialization::StreamingContext context), CODEPORTING_ARGS(info, context)); \
537 \
538 [[noreturn]] void DoThrow(const System::ExceptionPtr& self) const override { throw System::ExceptionWrapper<Details_##name>(self); } \
539 \
540 \
541 virtual String ExtraDescription() const override { return String::FromUtf8(std::to_string(m_##code)); } \
542 \
543 int m_##code = E_FAIL__; \
544};
545
549#define DECLARE_INHERITED_EXCEPTION_MSG_AND_HRESULT(name, parent, hresult) \
550class Details_##name; \
551using name = System::ExceptionWrapper<Details_##name>; \
552class ASPOSECPP_SHARED_CLASS Details_##name : public parent { \
553 friend class System::ExceptionWrapperHelper; \
554 template <typename T> friend class System::ExceptionWrapper; \
555 RTTI_INFO_NAMESPACE(name, System::BaseTypesInfo<parent>) \
556protected: \
557 \
558 using BaseType = parent; \
559 \
560 Details_##name() : parent(MessageDefault()) {m_HResult = hresult;} \
561 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(), CODEPORTING_ARGS()); \
562 \
563 \
564 Details_##name(const System::String &message) : parent(DefaultMessageIfNull(message)) {m_HResult = hresult;} \
565 MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(const System::String &message), CODEPORTING_ARGS(message)); \
566 \
567 \
568 \
569 Details_##name(const System::String &message, const System::ExceptionWrapper<System::Details_Exception>& innerException) \
570 : parent(DefaultMessageIfNull(message), innerException) {m_HResult = hresult;} \
571 MEMBER_FUNCTION_MAKE_OBJECT( Details_##name, \
572 CODEPORTING_ARGS(const System::String &message, const System::ExceptionWrapper<System::Details_Exception>& innerException), \
573 CODEPORTING_ARGS(message, innerException) \
574 ); \
575 \
576 [[noreturn]] void DoThrow(const System::ExceptionPtr& self) const override { throw System::ExceptionWrapper<Details_##name>(self); } \
577private: \
578 \
579 \
580 ASPOSECPP_SHARED_API static const String& MessageDefault(); \
581 \
582 \
583 \
584 ASPOSECPP_SHARED_API static const String& DefaultMessageIfNull(const String& message); \
585};
586
587EXCEPTION_NAMESPACE(, System) {
592 DECLARE_INHERITED_EXCEPTION_MSG(SystemException, System::Details_Exception);
597 DECLARE_INHERITED_EXCEPTION_MSG(ApplicationException, System::Details_Exception);
603 DECLARE_INHERITED_EXCEPTION_MSG(InvalidOperationException, System::Details_Exception);
608 DECLARE_INHERITED_EXCEPTION_MSG2(InvalidProgramException, System::Details_Exception);
613 DECLARE_INHERITED_EXCEPTION_MSG(InvalidTimeZoneException, System::Details_Exception);
618 DECLARE_INHERITED_EXCEPTION_MSG(TimeZoneNotFoundException, System::Details_Exception);
623 DECLARE_INHERITED_EXCEPTION_MSG_AND_EXTRA_NON_NULL_MEMBER(ObjectDisposedException, System::Details_InvalidOperationException, ObjectName);
628 DECLARE_INHERITED_EXCEPTION_MSG(NotImplementedException, System::Details_SystemException);
634 DECLARE_INHERITED_EXCEPTION_MSG(NotSupportedException, System::Details_SystemException);
639 DECLARE_INHERITED_EXCEPTION_MSG(PlatformNotSupportedException, System::Details_NotSupportedException);
644 DECLARE_INHERITED_EXCEPTION_MSG_AND_EXTRA_MEMBER(ArgumentException, System::Details_SystemException, ParamName);
650 DECLARE_INHERITED_EXCEPTION_MSG_AND_EXTRA_MEMBER2(ArgumentNullException, System::Details_ArgumentException, ParamName);
656 DECLARE_INHERITED_EXCEPTION_MSG_AND_EXTRA_MEMBER2(ArgumentOutOfRangeException, System::Details_ArgumentException, ParamName);
661 DECLARE_INHERITED_EXCEPTION_MSG(FormatException, System::Details_SystemException);
666 DECLARE_INHERITED_EXCEPTION_MSG2(UriFormatException, System::Details_FormatException);
672 DECLARE_INHERITED_EXCEPTION_MSG(ArithmeticException, System::Details_SystemException);
677 DECLARE_INHERITED_EXCEPTION_MSG(OverflowException, System::Details_ArithmeticException);
682 DECLARE_INHERITED_EXCEPTION_MSG(DivideByZeroException, System::Details_ArithmeticException);
687 DECLARE_INHERITED_EXCEPTION_MSG(OutOfMemoryException, System::Details_SystemException);
693 DECLARE_INHERITED_EXCEPTION_MSG2(IndexOutOfRangeException, System::Details_SystemException);
699 DECLARE_INHERITED_EXCEPTION_MSG(RankException, System::Details_SystemException);
704 DECLARE_INHERITED_EXCEPTION_MSG_AND_HRESULT(InvalidCastException, System::Details_SystemException, (int32_t)2147500034u);
709 DECLARE_INHERITED_EXCEPTION_MSG(NullReferenceException, System::Details_SystemException);
715 DECLARE_INHERITED_EXCEPTION_MSG2(UnauthorizedAccessException, System::Details_SystemException);
721 DECLARE_INHERITED_EXCEPTION_MSG(MemberAccessException, System::Details_SystemException);
727 DECLARE_INHERITED_EXCEPTION_MSG(MethodAccessException, System::Details_MemberAccessException);
734 DECLARE_INHERITED_EXCEPTION_MSG(OperationCanceledException, System::Details_SystemException);
739 DECLARE_INHERITED_EXCEPTION_MSG2(StackOverflowException, System::Details_SystemException);
744 DECLARE_INHERITED_EXCEPTION_MSG(TimeoutException, System::Details_SystemException);
747 DECLARE_INHERITED_EXCEPTION_MSG_AND_HRESULT(ExecutionEngineException, System::Details_SystemException, (int32_t)2148734214u);
749 DECLARE_INHERITED_EXCEPTION_MSG_AND_SUBSTITUTE_NON_NULL_MEMBER(TypeInitializationException, System::Details_SystemException, TypeName);
751 DECLARE_INHERITED_EXCEPTION_MSG(DataMisalignedException, System::Details_SystemException);
752
753 EXCEPTION_NAMESPACE(System, IO) {
755 DECLARE_INHERITED_EXCEPTION_MSG(IOException, System::Details_SystemException);
757 DECLARE_INHERITED_EXCEPTION_MSG(EndOfStreamException, System::IO::Details_IOException);
759 DECLARE_INHERITED_EXCEPTION_MSG2(InvalidDataException, System::Details_SystemException);
761 DECLARE_INHERITED_EXCEPTION_MSG(DirectoryNotFoundException, System::IO::Details_IOException);
763 DECLARE_INHERITED_EXCEPTION_MSG_AND_EXTRA_MEMBER(FileLoadException, System::IO::Details_IOException, FileName);
765 DECLARE_INHERITED_EXCEPTION_MSG(PathTooLongException, System::IO::Details_IOException);
766 }
767
768 EXCEPTION_NAMESPACE(System, Globalization) {
769 class Details_CultureNotFoundException;
771
776 friend class System::ExceptionWrapperHelper;
777 template <typename T> friend class System::ExceptionWrapper;
778 RTTI_INFO_NAMESPACE(CultureNotFoundException, System::BaseTypesInfo<System::Details_ArgumentException>)
779 public:
780 virtual Nullable<int> get_InvalidCultureId() const { return m_invalid_culture_id; }
781 virtual String get_InvalidCultureName() const { return m_invalid_culture_name; }
782 protected:
785 MEMBER_FUNCTION_MAKE_OBJECT(Details_CultureNotFoundException, CODEPORTING_ARGS(), CODEPORTING_ARGS());
786 Details_CultureNotFoundException(const String& message) : System::Details_ArgumentException(DefaultMessageIfNull(message)) {}
787 MEMBER_FUNCTION_MAKE_OBJECT(Details_CultureNotFoundException, CODEPORTING_ARGS(const String& message), CODEPORTING_ARGS(message));
788 Details_CultureNotFoundException(const String& paramName, const String& message) : System::Details_ArgumentException(DefaultMessageIfNull(message), paramName) {}
789 MEMBER_FUNCTION_MAKE_OBJECT(Details_CultureNotFoundException, CODEPORTING_ARGS(const String& paramName, const String& message), CODEPORTING_ARGS(paramName, message));
790 Details_CultureNotFoundException(const String& message, const System::ExceptionWrapper<System::Details_Exception>& innerException) : System::Details_ArgumentException(DefaultMessageIfNull(message), innerException) {}
791 MEMBER_FUNCTION_MAKE_OBJECT(Details_CultureNotFoundException,
792 CODEPORTING_ARGS(const String& message, const System::ExceptionWrapper<System::Details_Exception>& innerException),
793 CODEPORTING_ARGS(message, innerException)
794 );
795 Details_CultureNotFoundException(const String& paramName, int invalidCultureId, const String& message) : System::Details_ArgumentException(DefaultMessageIfNull(message), paramName), m_invalid_culture_id(invalidCultureId) {}
796 MEMBER_FUNCTION_MAKE_OBJECT(Details_CultureNotFoundException, CODEPORTING_ARGS(const String& paramName, int invalidCultureId, const String& message), CODEPORTING_ARGS(paramName, invalidCultureId, message));
797 Details_CultureNotFoundException(const String& message, int invalidCultureId, const System::ExceptionWrapper<System::Details_Exception>& innerException) : System::Details_ArgumentException(DefaultMessageIfNull(message), innerException), m_invalid_culture_id(invalidCultureId) {}
798 MEMBER_FUNCTION_MAKE_OBJECT(Details_CultureNotFoundException,
799 CODEPORTING_ARGS(const String& message, int invalidCultureId, const System::ExceptionWrapper<System::Details_Exception>& innerException),
800 CODEPORTING_ARGS(message, invalidCultureId, innerException)
801 );
802 Details_CultureNotFoundException(const String& paramName, const String& invalidCultureName, const String& message) : System::Details_ArgumentException(DefaultMessageIfNull(message), paramName), m_invalid_culture_name(invalidCultureName) {}
803 MEMBER_FUNCTION_MAKE_OBJECT(Details_CultureNotFoundException,
804 CODEPORTING_ARGS(const String& paramName, const String& invalidCultureName, const String& message),
805 CODEPORTING_ARGS(paramName, invalidCultureName, message)
806 );
807 Details_CultureNotFoundException(const String& message, const String& invalidCultureName, const System::ExceptionWrapper<System::Details_Exception>& innerException) : System::Details_ArgumentException(DefaultMessageIfNull(message), innerException), m_invalid_culture_name(invalidCultureName) {}
808 MEMBER_FUNCTION_MAKE_OBJECT(Details_CultureNotFoundException,
809 CODEPORTING_ARGS(const String& message, const String& invalidCultureName, const System::ExceptionWrapper<System::Details_Exception>& innerException),
810 CODEPORTING_ARGS(message, invalidCultureName, innerException)
811 );
813 MEMBER_FUNCTION_MAKE_OBJECT(Details_CultureNotFoundException,
815 CODEPORTING_ARGS(info, context)
816 );
817 [[noreturn]] void DoThrow(const System::ExceptionPtr& self) const override { throw System::ExceptionWrapper<Details_CultureNotFoundException>(self); }
818 private:
819 Nullable<int> m_invalid_culture_id;
820 String m_invalid_culture_name;
823 ASPOSECPP_SHARED_API static const String& MessageDefault();
827 ASPOSECPP_SHARED_API static const String& DefaultMessageIfNull(const String& message);
828 };
829 }
830
831 EXCEPTION_NAMESPACE(System, Security) {
834
835 EXCEPTION_NAMESPACE(System::Security, Cryptography) {
839 DECLARE_INHERITED_EXCEPTION_MSG(CryptographicUnexpectedOperationException,
840 System::Security::Cryptography::Details_CryptographicException);
841 }
842
843 EXCEPTION_NAMESPACE(System::Security, Authentication)
844 {
847 }
848 }
849
850 EXCEPTION_NAMESPACE(System, Threading) {
861 }
862
863 EXCEPTION_NAMESPACE(System, ComponentModel)
864 {
866 class Details_InvalidEnumArgumentException;
868
870 friend class System::ExceptionWrapperHelper;
871 template <typename T> friend class System::ExceptionWrapper;
872 RTTI_INFO_NAMESPACE(InvalidEnumArgumentException, System::BaseTypesInfo<System::Details_ArgumentException>)
873 protected:
875
877 MEMBER_FUNCTION_MAKE_OBJECT(Details_InvalidEnumArgumentException, CODEPORTING_ARGS(), CODEPORTING_ARGS());
878
879 Details_InvalidEnumArgumentException(const String& message) : System::Details_ArgumentException(DefaultMessageIfNull(message)) {}
880 MEMBER_FUNCTION_MAKE_OBJECT(Details_InvalidEnumArgumentException, CODEPORTING_ARGS(const String& message), CODEPORTING_ARGS(message));
881
882 Details_InvalidEnumArgumentException(const String& message, const System::ExceptionWrapper<System::Details_Exception>& innerException) : System::Details_ArgumentException(DefaultMessageIfNull(message), innerException) {}
883 MEMBER_FUNCTION_MAKE_OBJECT(Details_InvalidEnumArgumentException,
884 CODEPORTING_ARGS(const String& message, const System::ExceptionWrapper<System::Details_Exception>& innerException),
885 CODEPORTING_ARGS(message, innerException)
886 );
887
889 MEMBER_FUNCTION_MAKE_OBJECT(Details_InvalidEnumArgumentException,
891 CODEPORTING_ARGS(info, context)
892 );
893
894 Details_InvalidEnumArgumentException(const String& argumentName, int invalidValue, const System::TypeInfo& enumClass)
895 : System::Details_ArgumentException(DetailedMessage(argumentName, invalidValue, enumClass), argumentName) {}
896 MEMBER_FUNCTION_MAKE_OBJECT(Details_InvalidEnumArgumentException,
897 CODEPORTING_ARGS(const String& argumentName, int invalidValue, const System::TypeInfo& enumClass),
898 CODEPORTING_ARGS(argumentName, invalidValue, enumClass));
899
900 [[noreturn]] void DoThrow(const System::ExceptionPtr& self) const override { throw System::ExceptionWrapper<Details_InvalidEnumArgumentException>(self); }
901 private:
904 ASPOSECPP_SHARED_API static const String& MessageDefault();
908 ASPOSECPP_SHARED_API static const String& DefaultMessageIfNull(const String& message);
914 ASPOSECPP_SHARED_API static const String DetailedMessage(const String& argumentName, int invalidValue, const System::TypeInfo& enumClass);
915 };
916 }
917
918 EXCEPTION_NAMESPACE(System, Collections)
919 {
920 EXCEPTION_NAMESPACE(System::Collections, Generic)
921 {
924 }
925 }
926
927 EXCEPTION_NAMESPACE(System, Web)
928 {
930 DECLARE_INHERITED_EXCEPTION(HttpException, System::Details_Exception);
931 }
932
933 EXCEPTION_NAMESPACE(System, Runtime)
934 {
935 EXCEPTION_NAMESPACE(System::Runtime, Serialization)
936 {
939 }
940 }
941}
942
943EXCEPTION_NAMESPACE(,NUnit)
944{
945 EXCEPTION_NAMESPACE(NUnit, Framework)
946 {
947 using System::SystemException;
950 }
951}
952
957#define CODEPORTING_USER_EXCEPTION_BEGIN(ns, name, base) class Details_##name; \
958using name = System::ExceptionWrapper<Details_##name>; \
959class Details_##name : public base \
960{ \
961 typedef Details_##name ThisType; \
962 typedef base BaseType; \
963 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo; \
964 RTTI_INFO_NAMED(Details_##name, #ns"::"#name, ThisTypeBaseTypesInfo); \
965 friend class ::System::ExceptionWrapperHelper; \
966 template <typename T> friend class ::System::ExceptionWrapper; \
967protected: \
968 [[noreturn]] void DoThrow(const ::System::ExceptionPtr& self) const override \
969 { \
970 throw ::System::ExceptionWrapper<Details_##name>(self); \
971 }
972
974#define CODEPORTING_USER_EXCEPTION_END };
975
981#define CODEPORTING_USER_EXCEPTION_CONSTRUCTOR(name, args_with_types, args_without_types) protected: \
982MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(args_with_types), CODEPORTING_ARGS(args_without_types)); \
983Details_##name(args_with_types)
984
991#define CODEPORTING_DECLARE_USER_EXCEPTION_BEGIN(class_api, method_api, ns, name, base) class Details_##name; \
992using name = System::ExceptionWrapper<Details_##name>; \
993class class_api Details_##name : public base \
994{ \
995 typedef Details_##name ThisType; \
996 typedef base BaseType; \
997 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo; \
998 RTTI_INFO_NAMED_DECLARE_EXPORTED(method_api, Details_##name, #ns"::"#name, ThisTypeBaseTypesInfo); \
999 friend class ::System::ExceptionWrapperHelper; \
1000 template <typename T> friend class ::System::ExceptionWrapper; \
1001protected: \
1002 [[noreturn]] method_api void DoThrow(const ::System::ExceptionPtr& self) const override;
1003
1009#define CODEPORTING_EXPORTED_USER_EXCEPTION_CONSTRUCTOR(method_api, name, args_with_types, args_without_types) protected: \
1010MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(args_with_types), CODEPORTING_ARGS(args_without_types)); \
1011method_api Details_##name(args_with_types);
1012
1013#define CODEPORTING_USER_EXCEPTION_IMPLEMENTATION(class_api, method_api, ns, name, base) \
1014const ::System::TypeInfo& ns::Details_##name::Type() { \
1015 return *System::static_holder<ThisTypeInfo>(); \
1016} \
1017const System::TypeInfo& ns::Details_##name::GetType() const { \
1018 return Details_##name::Type(); \
1019} \
1020bool ns::Details_##name::Is(const System::TypeInfo &target) const { \
1021 const System::TypeInfo& thisis = Details_##name::Type(); \
1022 return (thisis == target) ? true : ThisTypeBaseTypesInfo::CallIsForAll(this, target); \
1023} \
1024[[noreturn]] void ns::Details_##name::DoThrow(const ::System::ExceptionPtr& self) const \
1025{ \
1026 throw ::System::ExceptionWrapper<Details_##name>(self); \
1027} \
1028ns::Details_##name::ThisTypeInfo::ThisTypeInfo() \
1029 : System::TypeInfoPtr(ASPOSE_T(#ns) ASPOSE_T(#name), 0) \
1030{ \
1031}
Details_InvalidEnumArgumentException(const String &message)
Definition: exceptions.h:879
Details_InvalidEnumArgumentException()
Definition: exceptions.h:876
void DoThrow(const System::ExceptionPtr &self) const override
Definition: exceptions.h:900
Details_InvalidEnumArgumentException(const String &message, const System::ExceptionWrapper< System::Details_Exception > &innerException)
Definition: exceptions.h:882
Details_InvalidEnumArgumentException(const String &argumentName, int invalidValue, const System::TypeInfo &enumClass)
Definition: exceptions.h:894
System::Details_ArgumentException BaseType
Definition: exceptions.h:874
Details_InvalidEnumArgumentException(const System::SharedPtr< System::Runtime::Serialization::SerializationInfo > &info, System::Runtime::Serialization::StreamingContext context)
Definition: exceptions.h:888
ArgumentException is thrown when an argument passed to a method being invoked is invalid....
ArithmeticException is throw when an error occurs during execution of arithmetic, conversion of casti...
Represents an exception. Never create instances of this class manually. Use the Exception class inste...
Definition: exception.h:277
FormatException is thrown when the format of the method's argument is not valid. Never create instanc...
The exception that is thrown when a method is invoked on an object which is in the state inconsistent...
MemberAccessException is thrown when access to non-existent class' member is attempted or when access...
NotSupportedException is thrown when a method being invoked is not supported or when an operation att...
A base class for classes that represent system (rather than application) exceptions....
Template that represents wrapper of exceptions that are derived from Exception class.
Definition: exception.h:113
CultureNotFoundException is thrown when an attempt is made to construct a culture that is not availab...
Definition: exceptions.h:775
void DoThrow(const System::ExceptionPtr &self) const override
Definition: exceptions.h:817
Details_CultureNotFoundException(const String &message, int invalidCultureId, const System::ExceptionWrapper< System::Details_Exception > &innerException)
Definition: exceptions.h:797
System::Details_ArgumentException BaseType
Definition: exceptions.h:783
Details_CultureNotFoundException(const String &paramName, int invalidCultureId, const String &message)
Definition: exceptions.h:795
Details_CultureNotFoundException(const String &message)
Definition: exceptions.h:786
Details_CultureNotFoundException(const String &message, const String &invalidCultureName, const System::ExceptionWrapper< System::Details_Exception > &innerException)
Definition: exceptions.h:807
Details_CultureNotFoundException(const String &paramName, const String &message)
Definition: exceptions.h:788
Details_CultureNotFoundException(const System::SharedPtr< System::Runtime::Serialization::SerializationInfo > &info, System::Runtime::Serialization::StreamingContext context)
Definition: exceptions.h:812
virtual Nullable< int > get_InvalidCultureId() const
Definition: exceptions.h:780
virtual String get_InvalidCultureName() const
Definition: exceptions.h:781
Details_CultureNotFoundException(const String &paramName, const String &invalidCultureName, const String &message)
Definition: exceptions.h:802
Details_CultureNotFoundException()
Definition: exceptions.h:784
Details_CultureNotFoundException(const String &message, const System::ExceptionWrapper< System::Details_Exception > &innerException)
Definition: exceptions.h:790
Dummy class to make StreamingContext-using translated classes compile. Do not manage instances of thi...
Definition: streaming_context.h:12
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
Represents a particular type and provides information about it.
Definition: type_info.h:109
Definition: exceptions.h:943
Definition: algorithms.h:9
Definition: exception.h:18
Definition: ssl_enum_types.h:5
Definition: db_command.h:9
DECLARE_INHERITED_EXCEPTION_MSG(SystemException, System::Details_Exception)