PLCnext API Documentation 26.6.0.38
ArgumentOutOfRangeException.hpp
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
8#include "Arp/Base/Core/PimplPtr.hxx"
9#include "Arp/Base/Commons/Exceptions/ArgumentException.hpp"
10
11namespace Arp::Base::Commons::Exceptions
12{
13
15class ARP_BASE_COMMONS_EXPORT ArgumentOutOfRangeException : public ArgumentException
16{
17public: // Impl forward declaration
18 class Impl;
19
20public: // construction
21 template<typename... Args>
22 explicit ArgumentOutOfRangeException(const char* message, const Args& ... args);
23 explicit ArgumentOutOfRangeException(String&& message);
24 explicit ArgumentOutOfRangeException(const String& message);
25 ArgumentOutOfRangeException(String&& message, const Exception& innerException);
26 ArgumentOutOfRangeException(const String& message, const Exception& innerException);
27
28 // canonical construction/destruction/assignment
34
35protected: // construction
36 ArgumentOutOfRangeException(ExceptionTypeId typeId, String&& message, StackCounter stackCounter);
37 ArgumentOutOfRangeException(ExceptionTypeId typeId, const String& message, StackCounter stackCounter);
38 ArgumentOutOfRangeException(ExceptionTypeId typeId, String&& message, const Exception& innerException, StackCounter stackCounter);
39 ArgumentOutOfRangeException(ExceptionTypeId typeId, const String& message, const Exception& innerException, StackCounter stackCounter);
40
41public: // static factory operations
42 template<class T>
43 static ArgumentOutOfRangeException Create(const char* paramName, const T& paramValue);
44 template<class T>
45 static ArgumentOutOfRangeException Create(const char* paramName, const T& paramValue, const char* message);
46 template<class T>
47 static ArgumentOutOfRangeException Create(const char* paramName, const T& paramValue, const Exception& innerException);
48
49public: // internal operations
50 Impl& GetImpl(void);
51 const Impl& GetImpl(void)const;
52
53protected: // overridden operations
54 Exception::Ptr Clone(void)const override ;
55
56private: // static factory methods
57 static ArgumentOutOfRangeException CreateImpl(const char* paramName, const String& paramValue, StackCounter stackCounter);
58 static ArgumentOutOfRangeException CreateImpl(const char* paramName, const String& paramValue, const char* message, StackCounter stackCounter);
59 static ArgumentOutOfRangeException CreateImpl(const char* paramName, const String& paramValue, const Exception& innerException, StackCounter stackCounter);
60
61private: // Impl usings
63
64private: // Impl fields
65 Pimpl pimpl;
66};
67
69// inline methods of class ArgumentException
70
77template<typename... Args>
78inline ArgumentOutOfRangeException::ArgumentOutOfRangeException(const char* message, const Args& ... args)
79 : ArgumentOutOfRangeException(ExceptionTypeId::ArgumentNull, String::Format(message, args...), StackCounter())
80{
81}
82
90template<class T>
91inline ArgumentOutOfRangeException ArgumentOutOfRangeException::Create(const char* paramName, const T& paramValue)
92{
93 return CreateImpl(paramName, String::Format("{}", paramValue), StackCounter());
94}
95
104template<class T>
105inline ArgumentOutOfRangeException ArgumentOutOfRangeException::Create(const char* paramName, const T& paramValue, const char* message)
106{
107 return CreateImpl(paramName, String::Format("{}", paramValue), message, StackCounter());
108}
109
118template<class T>
119inline ArgumentOutOfRangeException ArgumentOutOfRangeException::Create(const char* paramName, const T& paramValue, const Exception& innerException)
120{
121 return CreateImpl(paramName, String::Format("{}", paramValue), innerException, StackCounter());
122}
123
124} // end of namespace Arp::Base::Commons::Exceptions
125
126namespace Arp {
127// Import exception into Arp namespace as Arp::System::Commons library does
129} // end of namespace Arp
131// template specialization of ArgumentOutOfRangeException formatter
132template<> struct fmt::formatter<Arp::Base::Commons::Exceptions::ArgumentOutOfRangeException> : public fmt::ostream_formatter {};
This exception is thrown when an invalid argument occurs.
Definition: ArgumentException.hpp:17
This exception is thrown when an invalid null argument occurs.
Definition: ArgumentOutOfRangeException.hpp:16
~ArgumentOutOfRangeException(void) override
Default destructor.
static ArgumentOutOfRangeException Create(const char *paramName, const T &paramValue)
Creates an ArgumentOutOfRangeException using a default message.
Definition: ArgumentOutOfRangeException.hpp:91
ArgumentOutOfRangeException(const ArgumentOutOfRangeException &arg)
Default copy constructor.
ArgumentOutOfRangeException(ArgumentOutOfRangeException &&arg) noexcept
Default move constructor.
ArgumentOutOfRangeException & operator=(ArgumentOutOfRangeException &&arg) noexcept
Default move-assignment operator.
ArgumentOutOfRangeException & operator=(const ArgumentOutOfRangeException &arg)
Default copy-assignment operator.
ArgumentOutOfRangeException(const char *message, const Args &... args)
Creates an ArgumentOutOfRangeException with message.
Definition: ArgumentOutOfRangeException.hpp:78
This class is used to count sequenced operation calls, which are e.g. invoked during an exception thr...
Definition: StackCounter.hpp:20
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
Adapter class to implement PImpl idiom.
Definition: PimplPtr.hxx:15
This class represents the Arp String. The implementation is based on std::string.
Definition: String.hpp:39
static String Format(const String &format, const Args &... args)
Formats the format string using the .NET/Python syntax with the given variadic arguments.
Definition: String.inl:18
@ Create
Creates a new file. If the file already exists, it is overwritten.
ExceptionTypeId
Specifies the type id of any exception derived by <see cref="CommonException".
Definition: ExceptionTypeId.hpp:15
Root namespace for the PLCnext API