PLCnext API Documentation  21.0.0.35466
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 
13 using namespace Arp::System::Commons;
14 
17 {
18 public: // construction/destruction
19  template<typename... Args>
20  PlcException(const char* message, const Args& ... args);
21  PlcException(const String& message);
22  PlcException(String&& message);
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 
29 protected: // construction
30  PlcException(ExceptionTypeId typeId, String&& message, int skipStackTraceDepth = 3);
31  PlcException(ExceptionTypeId typeId, const String& message, int skipStackTraceDepth = 3);
32  PlcException(ExceptionTypeId typeId, String&& message, Exception&& innerException, int skipStackTraceDepth = 3);
33  PlcException(ExceptionTypeId typeId, const String& message, const Exception& innerException, int skipStackTraceDepth = 3);
34 
35 public: // static factory methods
36  static PlcException Create(int exc, const String& stackTrace);
37 
38 protected: // overridden operations
39  Exception::Ptr Clone(void)const override;
40 
41 private: // deleted methods
42  PlcException& operator=(const PlcException& arg) = delete;
43 
44 private:
45  static const char* const defaultMessage;
46 };
47 
49 // inline methods of class PlcException
50 
52 template<typename... Args>
53 inline PlcException::PlcException(const char* message, const Args& ... args)
54  : CommonException(ExceptionTypeId::Plc, String::Format(message, args...))
55 {
56 }
57 
59 inline PlcException::PlcException(const String& message)
60  : CommonException(ExceptionTypeId::Plc, message)
61 {
62 }
63 
66  : CommonException(ExceptionTypeId::Plc, std::move(message))
67 {
68 }
69 
71 inline PlcException::PlcException(const String& message, const Exception& innerException)
72  : CommonException(ExceptionTypeId::Plc, message, innerException)
73 {
74 }
75 
77 inline PlcException::PlcException(String&& message, Exception&& innerException)
78  : CommonException(ExceptionTypeId::Plc, std::move(message), std::move(innerException))
79 {
80 }
81 
83 inline PlcException::PlcException(ExceptionTypeId typeId, const String& message, int skipStackTraceDepth)
84  : CommonException(typeId, std::move(message), skipStackTraceDepth)
85 {
86 }
87 
89 inline PlcException::PlcException(ExceptionTypeId typeId, String&& message, int skipStackTraceDepth)
90  : CommonException(typeId, std::move(message), skipStackTraceDepth)
91 {
92 }
93 
95 inline PlcException::PlcException(ExceptionTypeId typeId, const String& message, const Exception& innerException, int skipStackTraceDepth)
96  : CommonException(typeId, message, innerException, skipStackTraceDepth)
97 {
98 }
99 
101 inline PlcException::PlcException(ExceptionTypeId typeId, String&& message, Exception&& innerException, int skipStackTraceDepth)
102  : CommonException(typeId, std::move(message), std::move(innerException), skipStackTraceDepth)
103 {
104 }
105 
106 }}}} // end of namesapce Arp::System::Commons::Plc
This is the base class of common exception classes.
Definition: CommonException.hpp:18
Namespace of the C++ standard library
PlcException(const char *message, const Args &... args)
Constructs an PlcException instance.
Definition: PlcException.hpp:53
This exception is used when a $$$TODO$$$ occurs.
Definition: PlcException.hpp:16
std::shared_ptr< Exception > Ptr
The smart pointer tpye of this class.
Definition: Exception.hpp:19
ExceptionTypeId
Specifies the type id of any exception derived by <see cref="CommonException".
Definition: ExceptionTypeId.hpp:14
Root namespace for the PLCnext API
System components used by the System, Device, Plc or Io domains.
This is the base class of all Arp exception classes.
Definition: Exception.hpp:15
Namespace for basic functions of the framework
Definition: Console.hpp:14