PLCnext API Documentation 25.0.2.69
ArgumentNullException.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/ArgumentNullException.hpp"
9namespace Arp
10{
12}
13#else
14#include "Arp/System/Core/Arp.h"
15#include "Arp/System/Commons/Exceptions/ArgumentException.hpp"
16#include <type_traits>
17
18namespace Arp { namespace System { namespace Commons
19{
20
22class ArgumentNullException : public ArgumentException
23{
24public: // construction/destruction
25 template<typename... Args>
26 ArgumentNullException(const char* message, const Args& ... args);
27 ArgumentNullException(const String& message);
28 ArgumentNullException(String&& message);
29 ArgumentNullException(const String& message, const Exception& innerException);
30 ArgumentNullException(String&& message, Exception&& innerException);
31 ArgumentNullException(const ArgumentNullException& arg) = default;
32 ArgumentNullException(ArgumentNullException&& arg) = default;
33 virtual ~ArgumentNullException(void) = default;
34
35public: // static factory methods
36 static ArgumentNullException Create(const char* paramName);
37 static ArgumentNullException Create(const char* paramName, const Exception& innerException);
38
39protected: // overridden operations
40 Exception::Ptr Clone(void)const override;
41
42private: // deleted methods
43 ArgumentNullException& operator=(const ArgumentNullException& arg) = delete;
44
45private:
46 static const char* const defaultMessage;
47};
48
50// inline methods of class ArgumentNullException
51
53template<typename... Args>
54inline ArgumentNullException::ArgumentNullException(const char* message, const Args& ... args)
55 : ArgumentException(ExceptionTypeId::ArgumentNull, String::Format(message, args...))
56{
57}
58
60inline ArgumentNullException::ArgumentNullException(const String& message)
61 : ArgumentException(ExceptionTypeId::ArgumentNull, message)
62{
63}
64
66inline ArgumentNullException::ArgumentNullException(String&& message)
67 : ArgumentException(ExceptionTypeId::ArgumentNull, std::move(message))
68{
69}
70
72inline ArgumentNullException::ArgumentNullException(const String& message, const Exception& innerException)
73 : ArgumentException(ExceptionTypeId::ArgumentNull, message, innerException)
74{
75}
76
78inline ArgumentNullException::ArgumentNullException(String&& message, Exception&& innerException)
79 : ArgumentException(ExceptionTypeId::ArgumentNull, std::move(message), std::move(innerException))
80{
81}
82
84inline ArgumentNullException ArgumentNullException::Create(const char* paramName)
85{
86 return ArgumentNullException(defaultMessage, paramName);
87}
88
90inline ArgumentNullException ArgumentNullException::Create(const char* paramName, const Exception& innerException)
91{
92 return ArgumentNullException(String::Format(defaultMessage, paramName), innerException);
93}
94
95}}} // end of namesapce Arp::System::Commons
96
98// template specialization of ArgumentNullException formatter
99template<> struct fmt::formatter<Arp::System::Commons::ArgumentNullException> : public fmt::ostream_formatter {};
100
101#endif // ndef ARP_USE_ARP_SYSTEM_COMMONS_EXCEPTIONS
This exception is thrown when an invalid null argument occurs.
Definition: ArgumentNullException.hpp:16
ArgumentNullException(const ArgumentNullException &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