PLCnext API Documentation 25.0.2.69
PlcException.hpp
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
8#include "Arp/System/Commons/Exceptions/CommonException.hpp"
9
10namespace Arp { namespace System { namespace Commons { namespace Plc
11{
12
14{
15public: // construction/destruction
16 template<typename... Args>
17 PlcException(const char* message, const Args& ... args);
18 PlcException(const String& message);
19 PlcException(String&& message);
20 PlcException(const String& message, int skipStackTraceDepth);
21 PlcException(String&& message, int skipStackTraceDepth);
22 PlcException(const String& message, const Exception& innerException);
23 PlcException(String&& message, Exception&& innerException);
24 PlcException(const PlcException& arg) = default;
25 PlcException(PlcException&& arg) = default;
26 virtual ~PlcException(void) = default;
27
28protected: // construction
29 PlcException(ExceptionTypeId typeId, String&& message, int skipStackTraceDepth = DefaultSkipStackTraceDepth);
30 PlcException(ExceptionTypeId typeId, const String& message, int skipStackTraceDepth = DefaultSkipStackTraceDepth);
31 PlcException(ExceptionTypeId typeId, String&& message, Exception&& innerException, int skipStackTraceDepth = DefaultSkipStackTraceDepth);
32 PlcException(ExceptionTypeId typeId, const String& message, const Exception& innerException, int skipStackTraceDepth = DefaultSkipStackTraceDepth);
33
34public: // static factory methods
35 static PlcException Create(int exc, const String& message);
36 static PlcException CreateWithStackTrace(int exc, const String& message, const String& additionalStackTrace, int skipStackTraceDepth = 0);
37
38protected: // overridden operations
39 Exception::Ptr Clone(void)const override;
40
41private: // deleted methods
42 PlcException& operator=(const PlcException& arg) = delete;
43
44private:
45 static const char* const defaultMessage;
46
47protected:
48 static const int DefaultSkipStackTraceDepth = 3;
49};
50
52// inline methods of class PlcException
53
55template<typename... Args>
56inline PlcException::PlcException(const char* message, const Args& ... args)
57 : CommonException(ExceptionTypeId::Plc, String::Format(message, args...))
58{
59}
60
61
62}}}} // end of namesapce Arp::System::Commons::Plc
63
65// template specialization of PlcException formatter
66template<> struct fmt::formatter<Arp::System::Commons::Plc::PlcException> : public fmt::ostream_formatter {};
This is the base class of all Arp exception classes.
Definition: Exception.hpp:21
std::unique_ptr< Exception > Ptr
The smart pointer type of this class.
Definition: Exception.hpp:27
This class represents the Arp String. The implementation is based on std::string.
Definition: String.hpp:39
This is the base class of common exception classes.
Definition: CommonException.hpp:18
Definition: PlcException.hpp:14
static PlcException Create(int exc, const String &message)
Creates an PlcException instance using a default message text.
Definition: PlcException.cpp:21
Exception::Ptr Clone(void) const override
This operation clones this instance polymorpically as a deep copy.
Definition: PlcException.cpp:15
PlcException(const char *message, const Args &... args)
Constructs an PlcException instance.
Definition: PlcException.hpp:56
ExceptionTypeId
Specifies the type id of any exception derived by <see cref="CommonException".
Definition: ExceptionTypeId.hpp:15
Root namespace for the PLCnext API