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);
733 DECLARE_INHERITED_EXCEPTION_MSG(OperationCanceledException, System::Details_SystemException);
738 DECLARE_INHERITED_EXCEPTION_MSG2(StackOverflowException, System::Details_SystemException);
743 DECLARE_INHERITED_EXCEPTION_MSG(TimeoutException, System::Details_SystemException);
746 DECLARE_INHERITED_EXCEPTION_MSG_AND_HRESULT(ExecutionEngineException, System::Details_SystemException, (int32_t)2148734214u);
748 DECLARE_INHERITED_EXCEPTION_MSG_AND_SUBSTITUTE_NON_NULL_MEMBER(TypeInitializationException, System::Details_SystemException, TypeName);
750 DECLARE_INHERITED_EXCEPTION_MSG(DataMisalignedException, System::Details_SystemException);
751
752 EXCEPTION_NAMESPACE(System, IO) {
754 DECLARE_INHERITED_EXCEPTION_MSG(IOException, System::Details_SystemException);
756 DECLARE_INHERITED_EXCEPTION_MSG(EndOfStreamException, System::IO::Details_IOException);
758 DECLARE_INHERITED_EXCEPTION_MSG2(InvalidDataException, System::Details_SystemException);
760 DECLARE_INHERITED_EXCEPTION_MSG(DirectoryNotFoundException, System::IO::Details_IOException);
762 DECLARE_INHERITED_EXCEPTION_MSG_AND_EXTRA_MEMBER(FileLoadException, System::IO::Details_IOException, FileName);
764 DECLARE_INHERITED_EXCEPTION_MSG(PathTooLongException, System::IO::Details_IOException);
766 DECLARE_INHERITED_EXCEPTION_MSG(DriveNotFoundException, System::IO::Details_IOException);
767 }
768
769 EXCEPTION_NAMESPACE(System, Globalization) {
770 class Details_CultureNotFoundException;
772
777 friend class System::ExceptionWrapperHelper;
778 template <typename T> friend class System::ExceptionWrapper;
779 RTTI_INFO_NAMESPACE(CultureNotFoundException, System::BaseTypesInfo<System::Details_ArgumentException>)
780 public:
781 virtual Nullable<int> get_InvalidCultureId() const { return m_invalid_culture_id; }
782 virtual String get_InvalidCultureName() const { return m_invalid_culture_name; }
783 protected:
786 MEMBER_FUNCTION_MAKE_OBJECT(Details_CultureNotFoundException, CODEPORTING_ARGS(), CODEPORTING_ARGS());
787 Details_CultureNotFoundException(const String& message) : System::Details_ArgumentException(DefaultMessageIfNull(message)) {}
788 MEMBER_FUNCTION_MAKE_OBJECT(Details_CultureNotFoundException, CODEPORTING_ARGS(const String& message), CODEPORTING_ARGS(message));
789 Details_CultureNotFoundException(const String& paramName, const String& message) : System::Details_ArgumentException(DefaultMessageIfNull(message), paramName) {}
790 MEMBER_FUNCTION_MAKE_OBJECT(Details_CultureNotFoundException, CODEPORTING_ARGS(const String& paramName, const String& message), CODEPORTING_ARGS(paramName, message));
791 Details_CultureNotFoundException(const String& message, const System::ExceptionWrapper<System::Details_Exception>& innerException) : System::Details_ArgumentException(DefaultMessageIfNull(message), innerException) {}
792 MEMBER_FUNCTION_MAKE_OBJECT(Details_CultureNotFoundException,
793 CODEPORTING_ARGS(const String& message, const System::ExceptionWrapper<System::Details_Exception>& innerException),
794 CODEPORTING_ARGS(message, innerException)
795 );
796 Details_CultureNotFoundException(const String& paramName, int invalidCultureId, const String& message) : System::Details_ArgumentException(DefaultMessageIfNull(message), paramName), m_invalid_culture_id(invalidCultureId) {}
797 MEMBER_FUNCTION_MAKE_OBJECT(Details_CultureNotFoundException, CODEPORTING_ARGS(const String& paramName, int invalidCultureId, const String& message), CODEPORTING_ARGS(paramName, invalidCultureId, message));
798 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) {}
799 MEMBER_FUNCTION_MAKE_OBJECT(Details_CultureNotFoundException,
800 CODEPORTING_ARGS(const String& message, int invalidCultureId, const System::ExceptionWrapper<System::Details_Exception>& innerException),
801 CODEPORTING_ARGS(message, invalidCultureId, innerException)
802 );
803 Details_CultureNotFoundException(const String& paramName, const String& invalidCultureName, const String& message) : System::Details_ArgumentException(DefaultMessageIfNull(message), paramName), m_invalid_culture_name(invalidCultureName) {}
804 MEMBER_FUNCTION_MAKE_OBJECT(Details_CultureNotFoundException,
805 CODEPORTING_ARGS(const String& paramName, const String& invalidCultureName, const String& message),
806 CODEPORTING_ARGS(paramName, invalidCultureName, message)
807 );
808 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) {}
809 MEMBER_FUNCTION_MAKE_OBJECT(Details_CultureNotFoundException,
810 CODEPORTING_ARGS(const String& message, const String& invalidCultureName, const System::ExceptionWrapper<System::Details_Exception>& innerException),
811 CODEPORTING_ARGS(message, invalidCultureName, innerException)
812 );
814 MEMBER_FUNCTION_MAKE_OBJECT(Details_CultureNotFoundException,
816 CODEPORTING_ARGS(info, context)
817 );
818 [[noreturn]] void DoThrow(const System::ExceptionPtr& self) const override { throw System::ExceptionWrapper<Details_CultureNotFoundException>(self); }
819 private:
820 Nullable<int> m_invalid_culture_id;
821 String m_invalid_culture_name;
824 ASPOSECPP_SHARED_API static const String& MessageDefault();
828 ASPOSECPP_SHARED_API static const String& DefaultMessageIfNull(const String& message);
829 };
830 }
831
832 EXCEPTION_NAMESPACE(System, Security) {
835
836 EXCEPTION_NAMESPACE(System::Security, Cryptography) {
840 DECLARE_INHERITED_EXCEPTION_MSG(CryptographicUnexpectedOperationException,
841 System::Security::Cryptography::Details_CryptographicException);
842 }
843
844 EXCEPTION_NAMESPACE(System::Security, Authentication)
845 {
848 }
849 }
850
851 EXCEPTION_NAMESPACE(System, Threading) {
862 }
863
864 EXCEPTION_NAMESPACE(System, ComponentModel)
865 {
867 class Details_InvalidEnumArgumentException;
869
871 friend class System::ExceptionWrapperHelper;
872 template <typename T> friend class System::ExceptionWrapper;
873 RTTI_INFO_NAMESPACE(InvalidEnumArgumentException, System::BaseTypesInfo<System::Details_ArgumentException>)
874 protected:
876
878 MEMBER_FUNCTION_MAKE_OBJECT(Details_InvalidEnumArgumentException, CODEPORTING_ARGS(), CODEPORTING_ARGS());
879
880 Details_InvalidEnumArgumentException(const String& message) : System::Details_ArgumentException(DefaultMessageIfNull(message)) {}
881 MEMBER_FUNCTION_MAKE_OBJECT(Details_InvalidEnumArgumentException, CODEPORTING_ARGS(const String& message), CODEPORTING_ARGS(message));
882
883 Details_InvalidEnumArgumentException(const String& message, const System::ExceptionWrapper<System::Details_Exception>& innerException) : System::Details_ArgumentException(DefaultMessageIfNull(message), innerException) {}
884 MEMBER_FUNCTION_MAKE_OBJECT(Details_InvalidEnumArgumentException,
885 CODEPORTING_ARGS(const String& message, const System::ExceptionWrapper<System::Details_Exception>& innerException),
886 CODEPORTING_ARGS(message, innerException)
887 );
888
890 MEMBER_FUNCTION_MAKE_OBJECT(Details_InvalidEnumArgumentException,
892 CODEPORTING_ARGS(info, context)
893 );
894
895 Details_InvalidEnumArgumentException(const String& argumentName, int invalidValue, const System::TypeInfo& enumClass)
896 : System::Details_ArgumentException(DetailedMessage(argumentName, invalidValue, enumClass), argumentName) {}
897 MEMBER_FUNCTION_MAKE_OBJECT(Details_InvalidEnumArgumentException,
898 CODEPORTING_ARGS(const String& argumentName, int invalidValue, const System::TypeInfo& enumClass),
899 CODEPORTING_ARGS(argumentName, invalidValue, enumClass));
900
901 [[noreturn]] void DoThrow(const System::ExceptionPtr& self) const override { throw System::ExceptionWrapper<Details_InvalidEnumArgumentException>(self); }
902 private:
905 ASPOSECPP_SHARED_API static const String& MessageDefault();
909 ASPOSECPP_SHARED_API static const String& DefaultMessageIfNull(const String& message);
915 ASPOSECPP_SHARED_API static const String DetailedMessage(const String& argumentName, int invalidValue, const System::TypeInfo& enumClass);
916 };
917 }
918
919 EXCEPTION_NAMESPACE(System, Collections)
920 {
921 EXCEPTION_NAMESPACE(System::Collections, Generic)
922 {
925 }
926 }
927
928 EXCEPTION_NAMESPACE(System, Web)
929 {
931 DECLARE_INHERITED_EXCEPTION(HttpException, System::Details_Exception);
932 }
933
934 EXCEPTION_NAMESPACE(System, Runtime)
935 {
936 EXCEPTION_NAMESPACE(System::Runtime, Serialization)
937 {
940 }
941 }
942}
943
944EXCEPTION_NAMESPACE(,NUnit)
945{
946 EXCEPTION_NAMESPACE(NUnit, Framework)
947 {
948 using System::SystemException;
951 }
952}
953
958#define CODEPORTING_USER_EXCEPTION_BEGIN(ns, name, base) class Details_##name; \
959using name = System::ExceptionWrapper<Details_##name>; \
960class Details_##name : public base \
961{ \
962 typedef Details_##name ThisType; \
963 typedef base BaseType; \
964 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo; \
965 RTTI_INFO_NAMED(Details_##name, #ns"::"#name, ThisTypeBaseTypesInfo); \
966 friend class ::System::ExceptionWrapperHelper; \
967 template <typename T> friend class ::System::ExceptionWrapper; \
968protected: \
969 [[noreturn]] void DoThrow(const ::System::ExceptionPtr& self) const override \
970 { \
971 throw ::System::ExceptionWrapper<Details_##name>(self); \
972 }
973
975#define CODEPORTING_USER_EXCEPTION_END };
976
982#define CODEPORTING_USER_EXCEPTION_CONSTRUCTOR(name, args_with_types, args_without_types) protected: \
983MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(args_with_types), CODEPORTING_ARGS(args_without_types)); \
984Details_##name(args_with_types)
985
992#define CODEPORTING_DECLARE_USER_EXCEPTION_BEGIN(class_api, method_api, ns, name, base) class Details_##name; \
993using name = System::ExceptionWrapper<Details_##name>; \
994class class_api Details_##name : public base \
995{ \
996 typedef Details_##name ThisType; \
997 typedef base BaseType; \
998 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo; \
999 RTTI_INFO_NAMED_DECLARE_EXPORTED(method_api, Details_##name, #ns"::"#name, ThisTypeBaseTypesInfo); \
1000 friend class ::System::ExceptionWrapperHelper; \
1001 template <typename T> friend class ::System::ExceptionWrapper; \
1002protected: \
1003 [[noreturn]] method_api void DoThrow(const ::System::ExceptionPtr& self) const override;
1004
1010#define CODEPORTING_EXPORTED_USER_EXCEPTION_CONSTRUCTOR(method_api, name, args_with_types, args_without_types) protected: \
1011MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(args_with_types), CODEPORTING_ARGS(args_without_types)); \
1012method_api Details_##name(args_with_types);
1013
1014#define CODEPORTING_USER_EXCEPTION_IMPLEMENTATION(class_api, method_api, ns, name, base) \
1015const ::System::TypeInfo& ns::Details_##name::Type() { \
1016 return *System::static_holder<ThisTypeInfo>(); \
1017} \
1018const System::TypeInfo& ns::Details_##name::GetType() const { \
1019 return Details_##name::Type(); \
1020} \
1021bool ns::Details_##name::Is(const System::TypeInfo &target) const { \
1022 const System::TypeInfo& thisis = Details_##name::Type(); \
1023 return (thisis == target) ? true : ThisTypeBaseTypesInfo::CallIsForAll(this, target); \
1024} \
1025[[noreturn]] void ns::Details_##name::DoThrow(const ::System::ExceptionPtr& self) const \
1026{ \
1027 throw ::System::ExceptionWrapper<Details_##name>(self); \
1028} \
1029ns::Details_##name::ThisTypeInfo::ThisTypeInfo() \
1030 : System::TypeInfoPtr(ASPOSE_T(#ns) ASPOSE_T(#name), 0) \
1031{ \
1032}
Details_InvalidEnumArgumentException(const String &message)
Definition: exceptions.h:880
Details_InvalidEnumArgumentException()
Definition: exceptions.h:877
void DoThrow(const System::ExceptionPtr &self) const override
Definition: exceptions.h:901
Details_InvalidEnumArgumentException(const String &message, const System::ExceptionWrapper< System::Details_Exception > &innerException)
Definition: exceptions.h:883
Details_InvalidEnumArgumentException(const String &argumentName, int invalidValue, const System::TypeInfo &enumClass)
Definition: exceptions.h:895
System::Details_ArgumentException BaseType
Definition: exceptions.h:875
Details_InvalidEnumArgumentException(const System::SharedPtr< System::Runtime::Serialization::SerializationInfo > &info, System::Runtime::Serialization::StreamingContext context)
Definition: exceptions.h:889
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:282
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:118
CultureNotFoundException is thrown when an attempt is made to construct a culture that is not availab...
Definition: exceptions.h:776
void DoThrow(const System::ExceptionPtr &self) const override
Definition: exceptions.h:818
Details_CultureNotFoundException(const String &message, int invalidCultureId, const System::ExceptionWrapper< System::Details_Exception > &innerException)
Definition: exceptions.h:798
System::Details_ArgumentException BaseType
Definition: exceptions.h:784
Details_CultureNotFoundException(const String &paramName, int invalidCultureId, const String &message)
Definition: exceptions.h:796
Details_CultureNotFoundException(const String &message)
Definition: exceptions.h:787
Details_CultureNotFoundException(const String &message, const String &invalidCultureName, const System::ExceptionWrapper< System::Details_Exception > &innerException)
Definition: exceptions.h:808
Details_CultureNotFoundException(const String &paramName, const String &message)
Definition: exceptions.h:789
Details_CultureNotFoundException(const System::SharedPtr< System::Runtime::Serialization::SerializationInfo > &info, System::Runtime::Serialization::StreamingContext context)
Definition: exceptions.h:813
virtual Nullable< int > get_InvalidCultureId() const
Definition: exceptions.h:781
virtual String get_InvalidCultureName() const
Definition: exceptions.h:782
Details_CultureNotFoundException(const String &paramName, const String &invalidCultureName, const String &message)
Definition: exceptions.h:803
Details_CultureNotFoundException()
Definition: exceptions.h:785
Details_CultureNotFoundException(const String &message, const System::ExceptionWrapper< System::Details_Exception > &innerException)
Definition: exceptions.h:791
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:125
Represents a particular type and provides information about it.
Definition: type_info.h:109
Definition: exceptions.h:944
Definition: aggregate_exception.h:13
Definition: exception.h:18
Definition: ssl_enum_types.h:5
Definition: db_command.h:9
DECLARE_INHERITED_EXCEPTION_MSG(SystemException, System::Details_Exception)