CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
details_exception_with_filename.h
1
2
3#pragma once
4
5#include <type_traits>
6#include "system/exception.h"
7#include "system/environment.h"
8
9namespace System {
12template <typename T, typename = std::enable_if<std::is_base_of<Exception, T>::value>>
14{
15 String m_fileName;
16
17protected:
19 Details_ExceptionWithFilename() : T(), m_fileName(nullptr) {}
22 Details_ExceptionWithFilename(const String& message) : T(message), m_fileName(nullptr) {}
27 Details_ExceptionWithFilename(const String& message, const Exception& innerException)
28 : T(message, innerException), m_fileName(nullptr) {};
32 Details_ExceptionWithFilename(const String& message, const String& fileName) : T(message), m_fileName(fileName) {}
38 Details_ExceptionWithFilename(const String& message, const String& fileName, const Exception& innerException)
39 : T(message, innerException), m_fileName(fileName) {}
41 virtual String ExtraDescription() const override
42 {
43 return m_fileName;
44 }
45
46public:
48 virtual String get_FileName() const
49 {
50 return m_fileName;
51 }
53 virtual String get_Message() const override
54 {
55 return T::m_message;
56 }
58 virtual String ToString() const override
59 {
60 String result = T::ToString();
61 if (!m_fileName.IsNullOrEmpty())
62 {
63 result += System::Environment::get_NewLine() + u"Filename: '" + m_fileName + u"'";
64 }
65 return result;
66 }
67};
68} // namespace System
The template class for an exception with a file name.
Definition: details_exception_with_filename.h:14
Details_ExceptionWithFilename(const String &message)
Initializes a new instance with a specified error message and an empty file name.
Definition: details_exception_with_filename.h:22
virtual String ToString() const override
Definition: details_exception_with_filename.h:58
Details_ExceptionWithFilename()
Initializes a new instance with an empty file name.
Definition: details_exception_with_filename.h:19
virtual String ExtraDescription() const override
Definition: details_exception_with_filename.h:41
Details_ExceptionWithFilename(const String &message, const Exception &innerException)
Initializes a new instance with a specified error message, a reference to the inner exception that is...
Definition: details_exception_with_filename.h:27
Details_ExceptionWithFilename(const String &message, const String &fileName, const Exception &innerException)
Initializes a new instance with a specified error message, a reference to the inner exception that is...
Definition: details_exception_with_filename.h:38
virtual String get_FileName() const
Gets the name of the file that causes this exception.
Definition: details_exception_with_filename.h:48
virtual String get_Message() const override
Definition: details_exception_with_filename.h:53
Details_ExceptionWithFilename(const String &message, const String &fileName)
Initializes a new instance with a specified error message and a specified filename.
Definition: details_exception_with_filename.h:32
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
bool IsNullOrEmpty() const
Checks if string is empty or is considered null.
Definition: db_command.h:9
static String get_NewLine()
Returns the newline string set for the current environment.