CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
details_exception_with_error_code.h
1// @file system/details_exception_with_error_code.h
2
3#pragma once
4
5#include "system/convert.h"
6#include "system/exceptions.h"
7
8namespace System {
11template <typename T, typename = std::enable_if<std::is_base_of<Exception, T>::value>>
13{
15 static const int32_t DEFAULT_HRESULT = -2147467259;
16
17protected:
20 {
21 T::m_HResult = DEFAULT_HRESULT;
22 }
25 Details_ExceptionWithErrorCode(const String& message) : T(message)
26 {
27 T::m_HResult = DEFAULT_HRESULT;
28 }
34 Details_ExceptionWithErrorCode(const String& message, const System::Exception& innerException)
35 : T(message, innerException)
36 {
37 T::m_HResult = DEFAULT_HRESULT;
38 }
43 Details_ExceptionWithErrorCode(const String& message, int32_t errorCode) : T(message)
44 {
45 T::m_HResult = errorCode;
46 }
48 virtual String ExtraDescription() const override
49 {
50 return Convert::ToString(T::m_HResult);
51 }
52
53public:
55 virtual int32_t get_ErrorCode() const
56 {
57 return T::m_HResult;
58 }
60 virtual String get_Message() const override
61 {
62 return T::m_message == nullptr ? T::DefaultMessage() : T::m_message;
63 }
64};
65} // namespace System
The template class for an exception with an error code.
Definition: details_exception_with_error_code.h:13
virtual String get_Message() const override
Definition: details_exception_with_error_code.h:60
virtual int32_t get_ErrorCode() const
Gets the HRESULT of the error.
Definition: details_exception_with_error_code.h:55
Details_ExceptionWithErrorCode(const String &message, const System::Exception &innerException)
Initializes a new instance of the ExceptionWithErrorCode class with a specified error message and a r...
Definition: details_exception_with_error_code.h:34
Details_ExceptionWithErrorCode(const String &message)
Initializes a new instance of the ExceptionWithErrorCode class with a specified error message.
Definition: details_exception_with_error_code.h:25
Details_ExceptionWithErrorCode()
Initializes a new instance of the ExceptionWithErrorCode class with default properties.
Definition: details_exception_with_error_code.h:19
virtual String ExtraDescription() const override
Definition: details_exception_with_error_code.h:48
Details_ExceptionWithErrorCode(const String &message, int32_t errorCode)
Initializes a new instance of the ExceptionWithErrorCode class with a specified error message and the...
Definition: details_exception_with_error_code.h:43
Template that represents wrapper of exceptions that are derived from Exception class.
Definition: exception.h:113
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
Definition: db_command.h:9
static String ToString(int8_t value)
Converts the specified value to its string representation.