PLCnext API Documentation 25.0.2.69
NotAuthorizedException.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/NotAuthorizedException.hpp"
9namespace Arp
10{
12}
13#else
14#include "Arp/System/Core/Arp.h"
15#include "Arp/System/Commons/Exceptions/CommonException.hpp"
16
17namespace Arp { namespace System { namespace Commons
18{
19
21class NotAuthorizedException : public CommonException
22{
23public: // construction/destruction
24 template<typename... Args>
25 NotAuthorizedException(const char* message, const Args& ... args);
26 NotAuthorizedException(const String& message);
27 NotAuthorizedException(String&& message);
28 NotAuthorizedException(const String& message, const Exception& innerException);
29 NotAuthorizedException(String&& message, Exception&& innerException);
30 NotAuthorizedException(const NotAuthorizedException& arg) = default;
31 NotAuthorizedException(NotAuthorizedException&& arg) = default;
32 virtual ~NotAuthorizedException(void) = default;
33
34public: // static factory methods
35 static NotAuthorizedException Create(const char* failedAction);
36
37protected: // overridden operations
38 Exception::Ptr Clone(void)const override;
39
40private: // deleted methods
41 NotAuthorizedException& operator=(const NotAuthorizedException& arg) = delete;
42
43private:
44 static const char* const defaultMessage;
45};
46
48// inline methods of class NotAuthorizedException
49
51template<typename... Args>
52inline NotAuthorizedException::NotAuthorizedException(const char* message, const Args& ... args)
53 : CommonException(ExceptionTypeId::NotAuthorized, String::Format(message, args...))
54{
55}
56
58inline NotAuthorizedException::NotAuthorizedException(const String& message)
59 : CommonException(ExceptionTypeId::NotAuthorized, message)
60{
61}
62
64inline NotAuthorizedException::NotAuthorizedException(String&& message)
65 : CommonException(ExceptionTypeId::NotAuthorized, std::move(message))
66{
67}
68
70inline NotAuthorizedException::NotAuthorizedException(const String& message, const Exception& innerException)
71 : CommonException(ExceptionTypeId::NotAuthorized, message, innerException)
72{
73}
74
76inline NotAuthorizedException::NotAuthorizedException(String&& message, Exception&& innerException)
77 : CommonException(ExceptionTypeId::NotAuthorized, std::move(message), std::move(innerException))
78{
79}
80
82inline NotAuthorizedException NotAuthorizedException::Create(const char* failedAction)
83{
84 return NotAuthorizedException(defaultMessage, failedAction);
85}
86
87}}} // end of namesapce Arp::System::Commons
88
90// template specialization of NotAuthorizedException formatter
91template<> struct fmt::formatter<Arp::System::Commons::NotAuthorizedException> : public fmt::ostream_formatter {};
92
93#endif // ndef ARP_USE_ARP_SYSTEM_COMMONS_EXCEPTIONS
This exception is thrown when an operation is not authorized for the actual user.
Definition: NotAuthorizedException.hpp:16
NotAuthorizedException(const char *message, const Args &... args)
Creates an NotAuthorizedException with message.
Definition: NotAuthorizedException.hpp:67
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