PLCnext API Documentation 23.6.0.37
KeyNotFoundException.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 KeyNotFoundException(const char* message, const Args& ... args);
19 KeyNotFoundException(const String& message);
21 KeyNotFoundException(const String& message, const Exception& innerException);
22 KeyNotFoundException(String&& message, Exception&& innerException);
23 KeyNotFoundException(const KeyNotFoundException& arg) = default;
25 virtual ~KeyNotFoundException(void) = default;
26
27public: // static factory methods
28 template<class T>
29 static KeyNotFoundException Create(const T& keyValue);
30 template<class T>
31 static KeyNotFoundException Create(const T& keyValue, const Exception& innerException);
32
33protected: // overridden operations
34 Exception::Ptr Clone(void)const override;
35
36private: // deleted methods
37 KeyNotFoundException& operator=(const KeyNotFoundException& arg) = delete;
38
39private:
40 static const char* const defaultMessage;
41};
42
44// inline methods of class KeyNotFoundException
45
47template<typename... Args>
48inline KeyNotFoundException::KeyNotFoundException(const char* message, const Args& ... args)
49 : ArgumentException(ExceptionTypeId::KeyNotFound, String::Format(message, args...))
50{
51}
52
55 : ArgumentException(ExceptionTypeId::KeyNotFound, message)
56{
57}
58
61 : ArgumentException(ExceptionTypeId::KeyNotFound, std::move(message))
62{
63}
64
66inline KeyNotFoundException::KeyNotFoundException(const String& message, const Exception& innerException)
67 : ArgumentException(ExceptionTypeId::KeyNotFound, message, innerException)
68{
69}
70
73 : ArgumentException(ExceptionTypeId::KeyNotFound, std::move(message), std::move(innerException))
74{
75}
76
78template<class T>
80{
81 return KeyNotFoundException(defaultMessage, keyValue);
82}
83
85template<class T>
86inline KeyNotFoundException KeyNotFoundException::Create(const T& keyValue, const Exception& innerException)
87{
88 return KeyNotFoundException(String::Format(defaultMessage, keyValue), 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: KeyNotFoundException.hpp:15
static KeyNotFoundException Create(const T &keyValue)
Creates an KeyNotFoundException instance using a default message text.
Definition: KeyNotFoundException.hpp:79
KeyNotFoundException(const char *message, const Args &... args)
Constructs an KeyNotFoundException instance.
Definition: KeyNotFoundException.hpp:48
Exception::Ptr Clone(void) const override
Clones this instance.
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