PLCnext API Documentation 26.6.0.38
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: // construction
21 template<typename... Args>
22 explicit ArgumentNullException(const char* message, const Args& ... args);
23 explicit ArgumentNullException(String&& message);
24 explicit ArgumentNullException(const String& message);
25 ArgumentNullException(String&& message, const Exception& innerException);
26 ArgumentNullException(const String& message, const Exception& innerException);
27
28 // canonical construction/destruction/assignment
33 ~ArgumentNullException(void) override ;
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
80} // end of namespace Arp::Base::Commons::Exceptions
81
82namespace Arp {
83// Import exception into Arp namespace as Arp::System::Commons library does
85} // end of namespace Arp
87// template specialization of ArgumentNullException formatter
88template<> 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(const char *message, const Args &... args)
Creates an ArgumentNullException with message.
Definition: ArgumentNullException.hpp:75
ArgumentNullException & operator=(const ArgumentNullException &arg)
Default copy-assignment operator.
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