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);
765 }
766
767 EXCEPTION_NAMESPACE(System, Globalization) {
768 class Details_CultureNotFoundException;
770
775 friend class System::ExceptionWrapperHelper;
776 template <typename T> friend class System::ExceptionWrapper;
777 RTTI_INFO_NAMESPACE(CultureNotFoundException, System::BaseTypesInfo<System::Details_ArgumentException>)
778 public:
779 virtual Nullable<int> get_InvalidCultureId() const { return m_invalid_culture_id; }
780 virtual String get_InvalidCultureName() const { return m_invalid_culture_name; }
781 protected:
784 MEMBER_FUNCTION_MAKE_OBJECT(Details_CultureNotFoundException, CODEPORTING_ARGS(), CODEPORTING_ARGS());
785 Details_CultureNotFoundException(const String& message) : System::Details_ArgumentException(DefaultMessageIfNull(message)) {}
786 MEMBER_FUNCTION_MAKE_OBJECT(Details_CultureNotFoundException, CODEPORTING_ARGS(const String& message), CODEPORTING_ARGS(message));
787 Details_CultureNotFoundException(const String& paramName, const String& message) : System::Details_ArgumentException(DefaultMessageIfNull(message), paramName) {}
788 MEMBER_FUNCTION_MAKE_OBJECT(Details_CultureNotFoundException, CODEPORTING_ARGS(const String& paramName, const String& message), CODEPORTING_ARGS(paramName, message));
789 Details_CultureNotFoundException(const String& message, const System::ExceptionWrapper<System::Details_Exception>& innerException) : System::Details_ArgumentException(DefaultMessageIfNull(message), innerException) {}
790 MEMBER_FUNCTION_MAKE_OBJECT(Details_CultureNotFoundException,
791 CODEPORTING_ARGS(const String& message, const System::ExceptionWrapper<System::Details_Exception>& innerException),
792 CODEPORTING_ARGS(message, innerException)
793 );
794 Details_CultureNotFoundException(const String& paramName, int invalidCultureId, const String& message) : System::Details_ArgumentException(DefaultMessageIfNull(message), paramName), m_invalid_culture_id(invalidCultureId) {}
795 MEMBER_FUNCTION_MAKE_OBJECT(Details_CultureNotFoundException, CODEPORTING_ARGS(const String& paramName, int invalidCultureId, const String& message), CODEPORTING_ARGS(paramName, invalidCultureId, message));
796 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) {}
797 MEMBER_FUNCTION_MAKE_OBJECT(Details_CultureNotFoundException,
798 CODEPORTING_ARGS(const String& message, int invalidCultureId, const System::ExceptionWrapper<System::Details_Exception>& innerException),
799 CODEPORTING_ARGS(message, invalidCultureId, innerException)
800 );
801 Details_CultureNotFoundException(const String& paramName, const String& invalidCultureName, const String& message) : System::Details_ArgumentException(DefaultMessageIfNull(message), paramName), m_invalid_culture_name(invalidCultureName) {}
802 MEMBER_FUNCTION_MAKE_OBJECT(Details_CultureNotFoundException,
803 CODEPORTING_ARGS(const String& paramName, const String& invalidCultureName, const String& message),
804 CODEPORTING_ARGS(paramName, invalidCultureName, message)
805 );
806 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) {}
807 MEMBER_FUNCTION_MAKE_OBJECT(Details_CultureNotFoundException,
808 CODEPORTING_ARGS(const String& message, const String& invalidCultureName, const System::ExceptionWrapper<System::Details_Exception>& innerException),
809 CODEPORTING_ARGS(message, invalidCultureName, innerException)
810 );
812 MEMBER_FUNCTION_MAKE_OBJECT(Details_CultureNotFoundException,
814 CODEPORTING_ARGS(info, context)
815 );
816 [[noreturn]] void DoThrow(const System::ExceptionPtr& self) const override { throw System::ExceptionWrapper<Details_CultureNotFoundException>(self); }
817 private:
818 Nullable<int> m_invalid_culture_id;
819 String m_invalid_culture_name;
822 ASPOSECPP_SHARED_API static const String& MessageDefault();
826 ASPOSECPP_SHARED_API static const String& DefaultMessageIfNull(const String& message);
827 };
828 }
829
830 EXCEPTION_NAMESPACE(System, Security) {
833
834 EXCEPTION_NAMESPACE(System::Security, Cryptography) {
838 DECLARE_INHERITED_EXCEPTION_MSG(CryptographicUnexpectedOperationException,
839 System::Security::Cryptography::Details_CryptographicException);
840 }
841
842 EXCEPTION_NAMESPACE(System::Security, Authentication)
843 {
846 }
847 }
848
849 EXCEPTION_NAMESPACE(System, Threading) {
860 }
861
862 EXCEPTION_NAMESPACE(System, ComponentModel)
863 {
865 class Details_InvalidEnumArgumentException;
867
869 friend class System::ExceptionWrapperHelper;
870 template <typename T> friend class System::ExceptionWrapper;
871 RTTI_INFO_NAMESPACE(InvalidEnumArgumentException, System::BaseTypesInfo<System::Details_ArgumentException>)
872 protected:
874
876 MEMBER_FUNCTION_MAKE_OBJECT(Details_InvalidEnumArgumentException, CODEPORTING_ARGS(), CODEPORTING_ARGS());
877
878 Details_InvalidEnumArgumentException(const String& message) : System::Details_ArgumentException(DefaultMessageIfNull(message)) {}
879 MEMBER_FUNCTION_MAKE_OBJECT(Details_InvalidEnumArgumentException, CODEPORTING_ARGS(const String& message), CODEPORTING_ARGS(message));
880
881 Details_InvalidEnumArgumentException(const String& message, const System::ExceptionWrapper<System::Details_Exception>& innerException) : System::Details_ArgumentException(DefaultMessageIfNull(message), innerException) {}
882 MEMBER_FUNCTION_MAKE_OBJECT(Details_InvalidEnumArgumentException,
883 CODEPORTING_ARGS(const String& message, const System::ExceptionWrapper<System::Details_Exception>& innerException),
884 CODEPORTING_ARGS(message, innerException)
885 );
886
888 MEMBER_FUNCTION_MAKE_OBJECT(Details_InvalidEnumArgumentException,
890 CODEPORTING_ARGS(info, context)
891 );
892
893 Details_InvalidEnumArgumentException(const String& argumentName, int invalidValue, const System::TypeInfo& enumClass)
894 : System::Details_ArgumentException(DetailedMessage(argumentName, invalidValue, enumClass), argumentName) {}
895 MEMBER_FUNCTION_MAKE_OBJECT(Details_InvalidEnumArgumentException,
896 CODEPORTING_ARGS(const String& argumentName, int invalidValue, const System::TypeInfo& enumClass),
897 CODEPORTING_ARGS(argumentName, invalidValue, enumClass));
898
899 [[noreturn]] void DoThrow(const System::ExceptionPtr& self) const override { throw System::ExceptionWrapper<Details_InvalidEnumArgumentException>(self); }
900 private:
903 ASPOSECPP_SHARED_API static const String& MessageDefault();
907 ASPOSECPP_SHARED_API static const String& DefaultMessageIfNull(const String& message);
913 ASPOSECPP_SHARED_API static const String DetailedMessage(const String& argumentName, int invalidValue, const System::TypeInfo& enumClass);
914 };
915 }
916
917 EXCEPTION_NAMESPACE(System, Collections)
918 {
919 EXCEPTION_NAMESPACE(System::Collections, Generic)
920 {
923 }
924 }
925
926 EXCEPTION_NAMESPACE(System, Web)
927 {
929 DECLARE_INHERITED_EXCEPTION(HttpException, System::Details_Exception);
930 }
931
932 EXCEPTION_NAMESPACE(System, Runtime)
933 {
934 EXCEPTION_NAMESPACE(System::Runtime, Serialization)
935 {
938 }
939 }
940}
941
942EXCEPTION_NAMESPACE(,NUnit)
943{
944 EXCEPTION_NAMESPACE(NUnit, Framework)
945 {
946 using System::SystemException;
949 }
950}
951
956#define CODEPORTING_USER_EXCEPTION_BEGIN(ns, name, base) class Details_##name; \
957using name = System::ExceptionWrapper<Details_##name>; \
958class Details_##name : public base \
959{ \
960 typedef Details_##name ThisType; \
961 typedef base BaseType; \
962 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo; \
963 RTTI_INFO_NAMED(Details_##name, #ns"::"#name, ThisTypeBaseTypesInfo); \
964 friend class ::System::ExceptionWrapperHelper; \
965 template <typename T> friend class ::System::ExceptionWrapper; \
966protected: \
967 [[noreturn]] void DoThrow(const ::System::ExceptionPtr& self) const override \
968 { \
969 throw ::System::ExceptionWrapper<Details_##name>(self); \
970 }
971
973#define CODEPORTING_USER_EXCEPTION_END };
974
980#define CODEPORTING_USER_EXCEPTION_CONSTRUCTOR(name, args_with_types, args_without_types) protected: \
981MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(args_with_types), CODEPORTING_ARGS(args_without_types)); \
982Details_##name(args_with_types)
983
990#define CODEPORTING_DECLARE_USER_EXCEPTION_BEGIN(class_api, method_api, ns, name, base) class Details_##name; \
991using name = System::ExceptionWrapper<Details_##name>; \
992class class_api Details_##name : public base \
993{ \
994 typedef Details_##name ThisType; \
995 typedef base BaseType; \
996 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo; \
997 RTTI_INFO_NAMED_DECLARE_EXPORTED(method_api, Details_##name, #ns"::"#name, ThisTypeBaseTypesInfo); \
998 friend class ::System::ExceptionWrapperHelper; \
999 template <typename T> friend class ::System::ExceptionWrapper; \
1000protected: \
1001 [[noreturn]] method_api void DoThrow(const ::System::ExceptionPtr& self) const override;
1002
1008#define CODEPORTING_EXPORTED_USER_EXCEPTION_CONSTRUCTOR(method_api, name, args_with_types, args_without_types) protected: \
1009MEMBER_FUNCTION_MAKE_OBJECT(Details_##name, CODEPORTING_ARGS(args_with_types), CODEPORTING_ARGS(args_without_types)); \
1010method_api Details_##name(args_with_types);
1011
1012#define CODEPORTING_USER_EXCEPTION_IMPLEMENTATION(class_api, method_api, ns, name, base) \
1013const ::System::TypeInfo& ns::Details_##name::Type() { \
1014 return *System::static_holder<ThisTypeInfo>(); \
1015} \
1016const System::TypeInfo& ns::Details_##name::GetType() const { \
1017 return Details_##name::Type(); \
1018} \
1019bool ns::Details_##name::Is(const System::TypeInfo &target) const { \
1020 const System::TypeInfo& thisis = Details_##name::Type(); \
1021 return (thisis == target) ? true : ThisTypeBaseTypesInfo::CallIsForAll(this, target); \
1022} \
1023[[noreturn]] void ns::Details_##name::DoThrow(const ::System::ExceptionPtr& self) const \
1024{ \
1025 throw ::System::ExceptionWrapper<Details_##name>(self); \
1026} \
1027ns::Details_##name::ThisTypeInfo::ThisTypeInfo() \
1028 : System::TypeInfoPtr(ASPOSE_T(#ns) ASPOSE_T(#name), 0) \
1029{ \
1030}
Details_InvalidEnumArgumentException(const String &message)
Definition: exceptions.h:878
Details_InvalidEnumArgumentException()
Definition: exceptions.h:875
void DoThrow(const System::ExceptionPtr &self) const override
Definition: exceptions.h:899
Details_InvalidEnumArgumentException(const String &message, const System::ExceptionWrapper< System::Details_Exception > &innerException)
Definition: exceptions.h:881
Details_InvalidEnumArgumentException(const String &argumentName, int invalidValue, const System::TypeInfo &enumClass)
Definition: exceptions.h:893
System::Details_ArgumentException BaseType
Definition: exceptions.h:873
Details_InvalidEnumArgumentException(const System::SharedPtr< System::Runtime::Serialization::SerializationInfo > &info, System::Runtime::Serialization::StreamingContext context)
Definition: exceptions.h:887
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:774
void DoThrow(const System::ExceptionPtr &self) const override
Definition: exceptions.h:816
Details_CultureNotFoundException(const String &message, int invalidCultureId, const System::ExceptionWrapper< System::Details_Exception > &innerException)
Definition: exceptions.h:796
System::Details_ArgumentException BaseType
Definition: exceptions.h:782
Details_CultureNotFoundException(const String &paramName, int invalidCultureId, const String &message)
Definition: exceptions.h:794
Details_CultureNotFoundException(const String &message)
Definition: exceptions.h:785
Details_CultureNotFoundException(const String &message, const String &invalidCultureName, const System::ExceptionWrapper< System::Details_Exception > &innerException)
Definition: exceptions.h:806
Details_CultureNotFoundException(const String &paramName, const String &message)
Definition: exceptions.h:787
Details_CultureNotFoundException(const System::SharedPtr< System::Runtime::Serialization::SerializationInfo > &info, System::Runtime::Serialization::StreamingContext context)
Definition: exceptions.h:811
virtual Nullable< int > get_InvalidCultureId() const
Definition: exceptions.h:779
virtual String get_InvalidCultureName() const
Definition: exceptions.h:780
Details_CultureNotFoundException(const String &paramName, const String &invalidCultureName, const String &message)
Definition: exceptions.h:801
Details_CultureNotFoundException()
Definition: exceptions.h:783
Details_CultureNotFoundException(const String &message, const System::ExceptionWrapper< System::Details_Exception > &innerException)
Definition: exceptions.h:789
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:942
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)