PLCnext API Documentation 25.0.2.69
NotAuthorizedException.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/CommonExceptionBase.hpp"
10
11namespace Arp::Base::Commons::Exceptions
12{
13
15class ARP_BASE_COMMONS_EXPORT NotAuthorizedException : public CommonExceptionBase
16{
17public: // Impl forward declaration
18 class Impl;
19
20public: // construction/destruction/assignment
21 template<typename... Args>
22 explicit NotAuthorizedException(const char* message, const Args& ... args);
24 NotAuthorizedException(const String& message);
25 NotAuthorizedException(String&& message, const Exception& innerException);
26 NotAuthorizedException(const String& message, const Exception& innerException);
27
33
34protected: // construction
35 NotAuthorizedException(ExceptionTypeId typeId, String&& message, StackCounter stackCounter);
36
37public: // static factory operations
38 static NotAuthorizedException Create(const char* failedAction);
39
40public: // internal operations
41 Impl& GetImpl(void);
42 const Impl& GetImpl(void)const;
43
44protected: // overridden operations
45 Exception::Ptr Clone(void)const override;
46
47private: // static factory methods
48 static NotAuthorizedException CreateImpl(const String& failedOperation, StackCounter stackCounter);
49
50private: // Impl usings
52
53private: // Impl fields
54 Pimpl pimpl;
55};
56
58// inline methods of class ArgumentException
59
66template<typename... Args>
67inline NotAuthorizedException::NotAuthorizedException(const char* message, const Args& ... args)
68 : NotAuthorizedException(ExceptionTypeId::NotAuthorized, String::Format(message, args...), StackCounter())
69{
70}
71
72} // end of namespace Arp::Base::Commons::Exceptions
73
74namespace Arp {
75// Import exception into Arp namespace as Arp::System::Commons library does
77} // end of namespace Arp
79// template specialization of NotAuthorizedException formatter
80template<> struct fmt::formatter<Arp::Base::Commons::Exceptions::NotAuthorizedException> : public fmt::ostream_formatter {};
This class serves as base class for all Arp commons exceptions.
Definition: CommonExceptionBase.hpp:24
This exception is thrown when an operation is not authorized for the actual user.
Definition: NotAuthorizedException.hpp:16
NotAuthorizedException & operator=(const NotAuthorizedException &arg)
Default copy-assignment operator.
~NotAuthorizedException(void) override
Default destructor.
NotAuthorizedException(NotAuthorizedException &&arg) noexcept
Default move constructor.
NotAuthorizedException & operator=(NotAuthorizedException &&arg) noexcept
Default move-assignment operator.
NotAuthorizedException(const NotAuthorizedException &arg)
Default copy constructor.
NotAuthorizedException(const char *message, const Args &... args)
Creates an NotAuthorizedException with message.
Definition: NotAuthorizedException.hpp:67
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