PLCnext API Documentation 23.6.0.37
PlcException.hpp
1
2//
3// Copyright PHOENIX CONTACT Electronics GmbH
4//
6#pragma once
8#include "Arp/System/Commons/Exceptions/CommonException.hpp"
9
10namespace Arp { namespace System { namespace Commons { namespace Plc
11{
12
15{
16public: // construction/destruction
17 template<typename... Args>
18 PlcException(const char* message, const Args& ... args);
19 PlcException(const String& message);
20 PlcException(String&& message);
21 PlcException(const String& message, int skipStackTraceDepth);
22 PlcException(String&& message, int skipStackTraceDepth);
23 PlcException(const String& message, const Exception& innerException);
24 PlcException(String&& message, Exception&& innerException);
25 PlcException(const PlcException& arg) = default;
26 PlcException(PlcException&& arg) = default;
27 virtual ~PlcException(void) = default;
28
29protected: // construction
30 PlcException(ExceptionTypeId typeId, String&& message, int skipStackTraceDepth = DefaultSkipStackTraceDepth);
31 PlcException(ExceptionTypeId typeId, const String& message, int skipStackTraceDepth = DefaultSkipStackTraceDepth);
32 PlcException(ExceptionTypeId typeId, String&& message, Exception&& innerException, int skipStackTraceDepth = DefaultSkipStackTraceDepth);
33 PlcException(ExceptionTypeId typeId, const String& message, const Exception& innerException, int skipStackTraceDepth = DefaultSkipStackTraceDepth);
34
35public: // static factory methods
36 static PlcException Create(int exc, const String& message);
37 static PlcException CreateWithStackTrace(int exc, const String& message, const String& additionalStackTrace, int skipStackTraceDepth = 0);
38
39protected: // overridden operations
40 Exception::Ptr Clone(void)const override;
41
42private: // deleted methods
43 PlcException& operator=(const PlcException& arg) = delete;
44
45private:
46 static const char* const defaultMessage;
47
48protected:
49 static const int DefaultSkipStackTraceDepth = 3;
50};
51
53// inline methods of class PlcException
54
56template<typename... Args>
57inline PlcException::PlcException(const char* message, const Args& ... args)
58 : CommonException(ExceptionTypeId::Plc, String::Format(message, args...))
59{
60}
61
63inline PlcException::PlcException(const String& message)
64 : CommonException(ExceptionTypeId::Plc, message)
65{
66}
67
70 : CommonException(ExceptionTypeId::Plc, std::move(message))
71{
72}
73
75inline PlcException::PlcException(const String& message, int skipStackTraceDepth)
76 : CommonException(ExceptionTypeId::Plc, message, skipStackTraceDepth)
77{
78}
79
81inline PlcException::PlcException(String&& message, int skipStackTraceDepth)
82 : CommonException(ExceptionTypeId::Plc, std::move(message), skipStackTraceDepth)
83{
84}
85
87inline PlcException::PlcException(const String& message, const Exception& innerException)
88 : CommonException(ExceptionTypeId::Plc, message, innerException)
89{
90}
91
93inline PlcException::PlcException(String&& message, Exception&& innerException)
94 : CommonException(ExceptionTypeId::Plc, std::move(message), std::move(innerException))
95{
96}
97
99inline PlcException::PlcException(ExceptionTypeId typeId, const String& message, int skipStackTraceDepth)
100 : CommonException(typeId, message, skipStackTraceDepth)
101{
102}
103
105inline PlcException::PlcException(ExceptionTypeId typeId, String&& message, int skipStackTraceDepth)
106 : CommonException(typeId, std::move(message), skipStackTraceDepth)
107{
108}
109
111inline PlcException::PlcException(ExceptionTypeId typeId, const String& message, const Exception& innerException, int skipStackTraceDepth)
112 : CommonException(typeId, message, innerException, skipStackTraceDepth)
113{
114}
115
117inline PlcException::PlcException(ExceptionTypeId typeId, String&& message, Exception&& innerException, int skipStackTraceDepth)
118 : CommonException(typeId, std::move(message), std::move(innerException), skipStackTraceDepth)
119{
120}
121
122}}}} // end of namesapce Arp::System::Commons::Plc
This is the base class of all Arp exception classes.
Definition: Exception.hpp:16
std::shared_ptr< Exception > Ptr
The smart pointer tpye of this class.
Definition: Exception.hpp:19
This is the base class of common exception classes.
Definition: CommonException.hpp:19
This exception is used when a $$$TODO$$$ occurs.
Definition: PlcException.hpp:15
Exception::Ptr Clone(void) const override
Clones this instance.
PlcException(const char *message, const Args &... args)
Constructs an PlcException instance.
Definition: PlcException.hpp:57
@ System
System components used by the System, Device, Plc or Io domains.
ExceptionTypeId
Specifies the type id of any exception derived by <see cref="CommonException".
Definition: ExceptionTypeId.hpp:15
Root namespace for the PLCnext API
Namespace of the C++ standard library