PLCnext API Documentation 23.6.0.37
ArgumentException.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
11{
12
15{
16public: // construction/destruction
17 template<typename... Args>
18 ArgumentException(const char* message, const Args& ... args);
19 ArgumentException(const String& message);
20 ArgumentException(String&& message);
21 ArgumentException(const String& message, const Exception& innerException);
22 ArgumentException(String&& message, Exception&& innerException);
23 ArgumentException(const ArgumentException& arg) = default;
24 ArgumentException(ArgumentException&& arg) = default;
25 virtual ~ArgumentException(void) = default;
26
27protected: // construction
28 ArgumentException(ExceptionTypeId typeId, String&& message, int skipStackTraceDepth = 3);
29 ArgumentException(ExceptionTypeId typeId, const String& message, int skipStackTraceDepth = 3);
30 ArgumentException(ExceptionTypeId typeId, String&& message, Exception&& innerException, int skipStackTraceDepth = 3);
31 ArgumentException(ExceptionTypeId typeId, const String& message, const Exception& innerException, int skipStackTraceDepth = 3);
32
33public: // static factory methods
34 template<class T>
35 static ArgumentException Create(const char* paramName, const T& paramValue);
36 template<class T>
37 static ArgumentException Create(const char* paramName, const T& paramValue, const Exception& innerException);
38 template<class T>
39 static ArgumentException Create(const char* paramName, const T& paramValue, const char* message);
40
41protected: // overridden operations
42 Exception::Ptr Clone(void)const override;
43
44private: // deleted methods
45 ArgumentException& operator=(const ArgumentException& arg) = delete;
46
47private:
48 static const char* const defaultMessage;
49 static const char* const defaultMessage2;
50};
51
53// inline methods of class ArgumentException
54
56template<typename... Args>
57inline ArgumentException::ArgumentException(const char* message, const Args& ... args)
58 : CommonException(ExceptionTypeId::Argument, String::Format(message, args...))
59{
60}
61
64 : CommonException(ExceptionTypeId::Argument, message)
65{
66}
67
70 : CommonException(ExceptionTypeId::Argument, std::move(message))
71{
72}
73
75inline ArgumentException::ArgumentException(const String& message, const Exception& innerException)
76 : CommonException(ExceptionTypeId::Argument, message, innerException)
77{
78}
79
81inline ArgumentException::ArgumentException(String&& message, Exception&& innerException)
82 : CommonException(ExceptionTypeId::Argument, std::move(message), std::move(innerException))
83{
84}
85
87inline ArgumentException::ArgumentException(ExceptionTypeId typeId, const String& message, int skipStackTraceDepth)
88 : CommonException(typeId, message, skipStackTraceDepth)
89{
90}
91
93inline ArgumentException::ArgumentException(ExceptionTypeId typeId, String&& message, int skipStackTraceDepth)
94 : CommonException(typeId, std::move(message), skipStackTraceDepth)
95{
96}
97
99inline ArgumentException::ArgumentException(ExceptionTypeId typeId, const String& message, const Exception& innerException, int skipStackTraceDepth)
100 : CommonException(typeId, message, innerException, skipStackTraceDepth)
101{
102}
103
105inline ArgumentException::ArgumentException(ExceptionTypeId typeId, String&& message, Exception&& innerException, int skipStackTraceDepth)
106 : CommonException(typeId, std::move(message), std::move(innerException), skipStackTraceDepth)
107{
108}
109
111template<class T>
112inline ArgumentException ArgumentException::Create(const char* paramName, const T& paramValue)
113{
114 return ArgumentException(defaultMessage, paramName, paramValue);
115}
116
118template<class T>
119ArgumentException ArgumentException::Create(const char* paramName, const T& paramValue, const Exception& innerException)
120{
121 return ArgumentException(String::Format(defaultMessage, paramName, paramValue), innerException);
122}
123
125template<class T>
126ArgumentException ArgumentException::Create(const char* paramName, const T& paramValue, const char* message)
127{
128 return ArgumentException(String::Format(defaultMessage2, paramName, paramValue, message));
129}
130
131}}} // end of namesapce Arp::System::Commons
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 exception is used when an invalid argument occurs.
Definition: ArgumentException.hpp:15
ArgumentException(const char *message, const Args &... args)
Constructs an ArgumentException instance.
Definition: ArgumentException.hpp:57
static ArgumentException Create(const char *paramName, const T &paramValue)
Creates an ArgumentException instance using a default message text.
Definition: ArgumentException.hpp:112
Exception::Ptr Clone(void) const override
Clones this instance.
This is the base class of common exception classes.
Definition: CommonException.hpp:19
static SelfType Format(const SelfType &format, const Args &... args)
Formats the format string using the .NET/Python syntax with the given variadic arguments.
Definition: BasicString.hxx:1493
@ 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