PLCnext API Documentation 23.6.0.37
NotAuthorizedException.hpp
1
2//
3// Copyright PHOENIX CONTACT Electronics GmbH
4//
6#pragma once
8#include "Arp/System/Commons/Exceptions/CommonException.hpp"
9
10namespace Arp { namespace System { namespace Commons
11{
12
15{
16public: // construction/destruction
17 template<typename... Args>
18 NotAuthorizedException(const char* message, const Args& ... args);
19 NotAuthorizedException(const String& message);
21 NotAuthorizedException(const String& message, const Exception& innerException);
22 NotAuthorizedException(String&& message, Exception&& innerException);
25 virtual ~NotAuthorizedException(void) = default;
26
27public: // static factory methods
28 static NotAuthorizedException Create(const char* failedAction);
29
30protected: // overridden operations
31 Exception::Ptr Clone(void)const override;
32
33private: // deleted methods
34 NotAuthorizedException& operator=(const NotAuthorizedException& arg) = delete;
35
36private:
37 static const char* const defaultMessage;
38};
39
41// inline methods of class NotAuthorizedException
42
44template<typename... Args>
45inline NotAuthorizedException::NotAuthorizedException(const char* message, const Args& ... args)
46 : CommonException(ExceptionTypeId::NotAuthorized, String::Format(message, args...))
47{
48}
49
52 : CommonException(ExceptionTypeId::NotAuthorized, message)
53{
54}
55
58 : CommonException(ExceptionTypeId::NotAuthorized, std::move(message))
59{
60}
61
63inline NotAuthorizedException::NotAuthorizedException(const String& message, const Exception& innerException)
64 : CommonException(ExceptionTypeId::NotAuthorized, message, innerException)
65{
66}
67
70 : CommonException(ExceptionTypeId::NotAuthorized, std::move(message), std::move(innerException))
71{
72}
73
76{
77 return NotAuthorizedException(defaultMessage, failedAction);
78}
79
80}}} // 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 is the base class of common exception classes.
Definition: CommonException.hpp:19
This exception is thrown when an operation is not authorized for the actual user.
Definition: NotAuthorizedException.hpp:15
static NotAuthorizedException Create(const char *failedAction)
Creates an NotAuthorizedException instance using a default message text.
Definition: NotAuthorizedException.hpp:75
Exception::Ptr Clone(void) const override
Clones this instance.
NotAuthorizedException(const char *message, const Args &... args)
Constructs an NotAuthorizedException instance.
Definition: NotAuthorizedException.hpp:45
@ 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