PLCnext API Documentation 25.0.2.69
ArgumentNullException.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 ArgumentNullException : 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 ArgumentNullException(const char* message, const Args& ... args);
31 ArgumentNullException(const String& message);
32 ArgumentNullException(String&& message, const Exception& innerException);
33 ArgumentNullException(const String& message, const Exception& innerException);
34
35protected: // construction
36 ArgumentNullException(ExceptionTypeId typeId, String&& message, StackCounter stackCounter);
37 ArgumentNullException(ExceptionTypeId typeId, const String& message, StackCounter stackCounter);
38 ArgumentNullException(ExceptionTypeId typeId, String&& message, const Exception& innerException, StackCounter stackCounter);
39 ArgumentNullException(ExceptionTypeId typeId, const String& message, const Exception& innerException, StackCounter stackCounter);
40
41public: // static factory operations
42 static ArgumentNullException Create(const char* paramName);
43 static ArgumentNullException Create(const char* paramName, const char* message);
44 static ArgumentNullException Create(const char* paramName, const Exception& innerException);
45
46public: // internal operations
47 Impl& GetImpl(void);
48 const Impl& GetImpl(void)const;
49
50protected: // overridden operations
51 Exception::Ptr Clone(void)const override;
52
53private: // static factory methods
54 static ArgumentNullException CreateImpl(const char* paramName, StackCounter stackCounter);
55 static ArgumentNullException CreateImpl(const char* paramName, const char* message, StackCounter stackCounter);
56 static ArgumentNullException CreateImpl(const char* paramName, const Exception& innerException, StackCounter stackCounter);
57
58private: // Impl usings
60
61private: // Impl fields
62 Pimpl pimpl;
63};
64
66// inline methods of class ArgumentException
67
74template<typename... Args>
75inline ArgumentNullException::ArgumentNullException(const char* message, const Args& ... args)
76 : ArgumentNullException(ExceptionTypeId::ArgumentNull, String::Format(message, args...), StackCounter())
77{
78}
79
86{
87 return CreateImpl(paramName, StackCounter());
88}
89
96inline ArgumentNullException ArgumentNullException::Create(const char* paramName, const char* message)
97{
98 return CreateImpl(paramName, message, StackCounter());
99}
100
106inline ArgumentNullException ArgumentNullException::Create(const char* paramName, const Exception& innerException)
107{
108 return CreateImpl(paramName, innerException, StackCounter());
109}
110
111} // end of namespace Arp::Base::Commons::Exceptions
112
113namespace Arp {
114// Import exception into Arp namespace as Arp::System::Commons library does
116} // end of namespace Arp
118// template specialization of ArgumentNullException formatter
119template<> struct fmt::formatter<Arp::Base::Commons::Exceptions::ArgumentNullException> : 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: ArgumentNullException.hpp:16
ArgumentNullException & operator=(const ArgumentNullException &arg)
Default copy-assignment operator.
static ArgumentNullException Create(const char *paramName)
Creates an ArgumentNullException using a default message.
Definition: ArgumentNullException.hpp:85
ArgumentNullException(ArgumentNullException &&arg) noexcept
Default move constructor.
ArgumentNullException & operator=(ArgumentNullException &&arg) noexcept
Default move-assignment operator.
ArgumentNullException(const ArgumentNullException &arg)
Default copy constructor.
~ArgumentNullException(void) override
Default destructor.
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
@ 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