PLCnext API Documentation 25.0.2.69
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: // canonical construction/destruction/assignment
26
27public: // construction
28 template<typename... Args>
29 explicit ArgumentOutOfRangeException(const char* message, const Args& ... args);
31 ArgumentOutOfRangeException(const String& message);
32 ArgumentOutOfRangeException(String&& message, const Exception& innerException);
33 ArgumentOutOfRangeException(const String& message, const Exception& innerException);
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
89template<class T>
90inline ArgumentOutOfRangeException ArgumentOutOfRangeException::Create(const char* paramName, const T& paramValue)
91{
92 return CreateImpl(paramName, String::Format("{}", paramValue), StackCounter());
93}
94
102template<class T>
103inline ArgumentOutOfRangeException ArgumentOutOfRangeException::Create(const char* paramName, const T& paramValue, const char* message)
104{
105 return CreateImpl(paramName, String::Format("{}", paramValue), message, StackCounter());
106}
107
115template<class T>
116inline ArgumentOutOfRangeException ArgumentOutOfRangeException::Create(const char* paramName, const T& paramValue, const Exception& innerException)
117{
118 return CreateImpl(paramName, String::Format("{}", paramValue), innerException, StackCounter());
119}
120
121} // end of namespace Arp::Base::Commons::Exceptions
122
123namespace Arp {
124// Import exception into Arp namespace as Arp::System::Commons library does
126} // end of namespace Arp
128// template specialization of ArgumentOutOfRangeException formatter
129template<> 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:90
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.
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