PLCnext API Documentation  22.6.0.43
PlcException.hpp
1 //
3 // Copyright PHOENIX CONTACT Electronics GmbH
4 //
6 #pragma once
7 #include "Arp/System/Core/Arp.h"
8 #include "Arp/System/Commons/Exceptions/CommonException.hpp"
9 
10 namespace Arp { namespace System { namespace Commons { namespace Plc
11 {
12 
15 {
16 public: // 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, const Exception& innerException);
22  PlcException(String&& message, Exception&& innerException);
23  PlcException(const PlcException& arg) = default;
24  PlcException(PlcException&& arg) = default;
25  virtual ~PlcException(void) = default;
26 
27 protected: // construction
28  PlcException(ExceptionTypeId typeId, String&& message, int skipStackTraceDepth = 3);
29  PlcException(ExceptionTypeId typeId, const String& message, int skipStackTraceDepth = 3);
30  PlcException(ExceptionTypeId typeId, String&& message, Exception&& innerException, int skipStackTraceDepth = 3);
31  PlcException(ExceptionTypeId typeId, const String& message, const Exception& innerException, int skipStackTraceDepth = 3);
32 
33 public: // static factory methods
34  static PlcException Create(int exc, const String& stackTrace);
35 
36 protected: // overridden operations
37  Exception::Ptr Clone(void)const override;
38 
39 private: // deleted methods
40  PlcException& operator=(const PlcException& arg) = delete;
41 
42 private:
43  static const char* const defaultMessage;
44 };
45 
47 // inline methods of class PlcException
48 
50 template<typename... Args>
51 inline PlcException::PlcException(const char* message, const Args& ... args)
52  : CommonException(ExceptionTypeId::Plc, String::Format(message, args...))
53 {
54 }
55 
57 inline PlcException::PlcException(const String& message)
58  : CommonException(ExceptionTypeId::Plc, message)
59 {
60 }
61 
64  : CommonException(ExceptionTypeId::Plc, std::move(message))
65 {
66 }
67 
69 inline PlcException::PlcException(const String& message, const Exception& innerException)
70  : CommonException(ExceptionTypeId::Plc, message, innerException)
71 {
72 }
73 
75 inline PlcException::PlcException(String&& message, Exception&& innerException)
76  : CommonException(ExceptionTypeId::Plc, std::move(message), std::move(innerException))
77 {
78 }
79 
81 inline PlcException::PlcException(ExceptionTypeId typeId, const String& message, int skipStackTraceDepth)
82  : CommonException(typeId, std::move(message), skipStackTraceDepth)
83 {
84 }
85 
87 inline PlcException::PlcException(ExceptionTypeId typeId, String&& message, int skipStackTraceDepth)
88  : CommonException(typeId, std::move(message), skipStackTraceDepth)
89 {
90 }
91 
93 inline PlcException::PlcException(ExceptionTypeId typeId, const String& message, const Exception& innerException, int skipStackTraceDepth)
94  : CommonException(typeId, message, innerException, skipStackTraceDepth)
95 {
96 }
97 
99 inline PlcException::PlcException(ExceptionTypeId typeId, String&& message, Exception&& innerException, int skipStackTraceDepth)
100  : CommonException(typeId, std::move(message), std::move(innerException), skipStackTraceDepth)
101 {
102 }
103 
104 }}}} // 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:51
@ 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