PLCnext API Documentation  21.0.0.35466
ArgumentOutOfRangeException.hpp
1 //
3 // Copyright PHOENIX CONTACT Electronics GmbH
4 //
6 #pragma once
7 #include "Arp/System/Core/Arp.h"
8 #include "Arp/System/Commons/Exceptions/ArgumentException.hpp"
9 
10 namespace Arp { namespace System { namespace Commons
11 {
12 
15 {
16 public: // 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);
23  ArgumentOutOfRangeException(const ArgumentOutOfRangeException& arg) = default;
24  ArgumentOutOfRangeException(ArgumentOutOfRangeException&& arg) = default;
25  virtual ~ArgumentOutOfRangeException(void) = default;
26 
27 public: // 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 
33 protected: // overridden operations
34  Exception::Ptr Clone(void)const override;
35 
36 private: // deleted methods
37  ArgumentOutOfRangeException& operator=(const ArgumentOutOfRangeException& arg) = delete;
38 
39 private:
40  static const char* const defaultMessage;
41 };
42 
44 // inline methods of class ArgumentOutOfRangeException
45 
47 template<typename... Args>
48 inline 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 
66 inline ArgumentOutOfRangeException::ArgumentOutOfRangeException(const String& message, const Exception& innerException)
67  : ArgumentException(ExceptionTypeId::ArgumentOutOfRange, std::move(message), std::move(innerException))
68 {
69 }
70 
73  : ArgumentException(ExceptionTypeId::ArgumentOutOfRange, std::move(message), std::move(innerException))
74 {
75 }
76 
78 template<class T>
79 inline ArgumentOutOfRangeException ArgumentOutOfRangeException::Create(const char* paramName, const T& paramValue)
80 {
81  return ArgumentOutOfRangeException(defaultMessage, paramName, paramValue);
82 }
83 
85 template<class T>
86 inline 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
Exception::Ptr Clone(void) const override
Clones this instance.
String Format(int indentLevel, bool withInnerException) const override
Formats this exception using the given indent level.
Namespace of the C++ standard library
std::shared_ptr< Exception > Ptr
The smart pointer tpye of this class.
Definition: Exception.hpp:19
ExceptionTypeId
Specifies the type id of any exception derived by <see cref="CommonException".
Definition: ExceptionTypeId.hpp:14
This exception is used when an invalid argument occurs.
Definition: ArgumentException.hpp:14
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:1482
Root namespace for the PLCnext API
ArgumentOutOfRangeException(const char *message, const Args &... args)
Constructs an ArgumentOutOfRangeException instance.
Definition: ArgumentOutOfRangeException.hpp:48
System components used by the System, Device, Plc or Io domains.
This is the base class of all Arp exception classes.
Definition: Exception.hpp:15
This exception is used when an argument is out of range.
Definition: ArgumentOutOfRangeException.hpp:14
static ArgumentOutOfRangeException Create(const char *paramName, const T &paramValue)
Creates an ArgumentOutOfRangeException instance using a default message text.
Definition: ArgumentOutOfRangeException.hpp:79