PLCnext API Documentation 25.0.2.69
ArgumentOutOfRangeException.hpp
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
7#ifndef ARP_USE_ARP_SYSTEM_COMMONS_EXCEPTIONS
8#include "Arp/Base/Commons/Exceptions/ArgumentOutOfRangeException.hpp"
9namespace Arp
10{
12}
13#else
14#include "Arp/System/Core/Arp.h"
15#include "Arp/System/Commons/Exceptions/ArgumentException.hpp"
16
17namespace Arp { namespace System { namespace Commons
18{
19
21class ArgumentOutOfRangeException : public ArgumentException
22{
23public: // construction/destruction
24 template<typename... Args>
25 ArgumentOutOfRangeException(const char* message, const Args& ... args);
26 ArgumentOutOfRangeException(const String& message);
27 ArgumentOutOfRangeException(String&& message);
28 ArgumentOutOfRangeException(const String& message, const Exception& innerException);
29 ArgumentOutOfRangeException(String&& message, Exception&& innerException);
30 ArgumentOutOfRangeException(const ArgumentOutOfRangeException& arg) = default;
31 ArgumentOutOfRangeException(ArgumentOutOfRangeException&& arg) = default;
32 virtual ~ArgumentOutOfRangeException(void) = default;
33
34public: // static factory methods
35 template<class T>
36 static ArgumentOutOfRangeException Create(const char* paramName, const T& paramValue);
37 template<class T>
38 static ArgumentOutOfRangeException Create(const char* paramName, const T& paramValue, const Exception& innerException);
39
40protected: // overridden operations
41 Exception::Ptr Clone(void)const override;
42
43private: // deleted methods
44 ArgumentOutOfRangeException& operator=(const ArgumentOutOfRangeException& arg) = delete;
45
46private:
47 static const char* const defaultMessage;
48};
49
51// inline methods of class ArgumentOutOfRangeException
52
54template<typename... Args>
55inline ArgumentOutOfRangeException::ArgumentOutOfRangeException(const char* message, const Args& ... args)
56 : ArgumentException(ExceptionTypeId::ArgumentOutOfRange, String::Format(message, args...))
57{
58}
59
61inline ArgumentOutOfRangeException::ArgumentOutOfRangeException(const String& message)
62 : ArgumentException(ExceptionTypeId::ArgumentOutOfRange, message)
63{
64}
65
67inline ArgumentOutOfRangeException::ArgumentOutOfRangeException(String&& message)
68 : ArgumentException(ExceptionTypeId::ArgumentOutOfRange, std::move(message))
69{
70}
71
73inline ArgumentOutOfRangeException::ArgumentOutOfRangeException(const String& message, const Exception& innerException)
74 : ArgumentException(ExceptionTypeId::ArgumentOutOfRange, message, innerException)
75{
76}
77
79inline ArgumentOutOfRangeException::ArgumentOutOfRangeException(String&& message, Exception&& innerException)
80 : ArgumentException(ExceptionTypeId::ArgumentOutOfRange, std::move(message), std::move(innerException))
81{
82}
83
85template<class T>
86inline ArgumentOutOfRangeException ArgumentOutOfRangeException::Create(const char* paramName, const T& paramValue)
87{
88 return ArgumentOutOfRangeException(defaultMessage, paramName, paramValue);
89}
90
92template<class T>
93inline ArgumentOutOfRangeException ArgumentOutOfRangeException::Create(const char* paramName, const T& paramValue, const Exception& innerException)
94{
95 return ArgumentOutOfRangeException(String::Format(defaultMessage, paramName, paramValue), innerException);
96}
97
98}}} // end of namesapce Arp::System::Commons
99
101// template specialization of ArgumentOutOfRangeException formatter
102template<> struct fmt::formatter<Arp::System::Commons::ArgumentOutOfRangeException> : public fmt::ostream_formatter {};
103
104#endif // ndef ARP_USE_ARP_SYSTEM_COMMONS_EXCEPTIONS
This exception is thrown when an invalid null argument occurs.
Definition: ArgumentOutOfRangeException.hpp:16
ArgumentOutOfRangeException(const ArgumentOutOfRangeException &arg)
Default copy constructor.
std::unique_ptr< Exception > Ptr
The smart pointer type of this class.
Definition: Exception.hpp:27
@ 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
Namespace of the C++ standard library