PLCnext API Documentation 23.6.0.37
ArgumentOutOfRangeException.hpp
1
2//
3// Copyright PHOENIX CONTACT Electronics GmbH
4//
6#pragma once
8#include "Arp/System/Commons/Exceptions/ArgumentException.hpp"
9
10namespace Arp { namespace System { namespace Commons
11{
12
15{
16public: // construction/destruction
17 template<typename... Args>
18 ArgumentOutOfRangeException(const char* message, const Args& ... args);
19 ArgumentOutOfRangeException(const String& message);
21 ArgumentOutOfRangeException(const String& message, const Exception& innerException);
22 ArgumentOutOfRangeException(String&& message, Exception&& innerException);
25 virtual ~ArgumentOutOfRangeException(void) = default;
26
27public: // static factory methods
28 template<class T>
29 static ArgumentOutOfRangeException Create(const char* paramName, const T& paramValue);
30 template<class T>
31 static ArgumentOutOfRangeException Create(const char* paramName, const T& paramValue, const Exception& innerException);
32
33protected: // overridden operations
34 Exception::Ptr Clone(void)const override;
35
36private: // deleted methods
37 ArgumentOutOfRangeException& operator=(const ArgumentOutOfRangeException& arg) = delete;
38
39private:
40 static const char* const defaultMessage;
41};
42
44// inline methods of class ArgumentOutOfRangeException
45
47template<typename... Args>
48inline ArgumentOutOfRangeException::ArgumentOutOfRangeException(const char* message, const Args& ... args)
49 : ArgumentException(ExceptionTypeId::ArgumentOutOfRange, String::Format(message, args...))
50{
51}
52
55 : ArgumentException(ExceptionTypeId::ArgumentOutOfRange, message)
56{
57}
58
61 : ArgumentException(ExceptionTypeId::ArgumentOutOfRange, std::move(message))
62{
63}
64
67 : ArgumentException(ExceptionTypeId::ArgumentOutOfRange, message, innerException)
68{
69}
70
73 : ArgumentException(ExceptionTypeId::ArgumentOutOfRange, std::move(message), std::move(innerException))
74{
75}
76
78template<class T>
79inline ArgumentOutOfRangeException ArgumentOutOfRangeException::Create(const char* paramName, const T& paramValue)
80{
81 return ArgumentOutOfRangeException(defaultMessage, paramName, paramValue);
82}
83
85template<class T>
86inline ArgumentOutOfRangeException ArgumentOutOfRangeException::Create(const char* paramName, const T& paramValue, const Exception& innerException)
87{
88 return ArgumentOutOfRangeException(String::Format(defaultMessage, paramName, paramValue), innerException);
89}
90
91}}} // 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
This exception is used when an argument is out of range.
Definition: ArgumentOutOfRangeException.hpp:15
Exception::Ptr Clone(void) const override
Clones this instance.
static ArgumentOutOfRangeException Create(const char *paramName, const T &paramValue)
Creates an ArgumentOutOfRangeException instance using a default message text.
Definition: ArgumentOutOfRangeException.hpp:79
ArgumentOutOfRangeException(const char *message, const Args &... args)
Constructs an ArgumentOutOfRangeException instance.
Definition: ArgumentOutOfRangeException.hpp:48
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