PLCnext API Documentation 25.0.2.69
RscException.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/Core/ExceptionTypeId.hpp"
10#include "Arp/Base/Rsc/Commons/RscError.hpp"
11#include "Arp/Base/Rsc/Commons/Arp.Base.Rsc.Commons.hpp"
12#include "Arp/Base/Commons/Exceptions/CommonExceptionBase.hpp"
13
14namespace Arp::Base::Rsc::Commons
15{
16
17// Type imports
19
23class ARP_BASE_RSC_COMMONS_EXPORT RscException : public CommonExceptionBase
24{
25public: // Impl forward declaration
26 class Impl;
27
28public: // construction
29 RscException(RscError errorCode, const String& message);
30 RscException(RscError errorCode, const String& message, const Exception& innerException);
31 template<typename... Args>
32 RscException(RscError errorCode, const char* message, const Args& ... args);
33
34 // canonical construction/assignment/destruction
36 RscException(RscException&& arg)noexcept;
39 virtual ~RscException(void);
40
41public: // static factory methods
42 static RscException Create(RscError errorCode);
43 static RscException Create(RscError errorCode, const Exception& innerExeption);
44 template<typename... Args>
45 static RscException Create(RscError errorCode, const char* message, const Args& ... args);
46
47public: // setter/getter operations
48 RscError GetErrorCode(void)const;
49
50public: // internal operations
51 Impl& GetImpl(void);
52 const Impl& GetImpl(void)const;
53
54protected: // overridden operations
55 Exception::Ptr Clone(void)const override;
56
57private: // construction
58 RscException(StackCounter stackCounter, RscError errorCode, const String& message);
59 RscException(StackCounter stackCounter, RscError errorCode, const String& message, const Exception& innerException);
60
61private: // Impl usings
63
64private: // Impl fields
65 Pimpl pimpl;
66};
67
69// inline methods of class RscException
70
76template<typename... Args>
77inline RscException::RscException(RscError errorCode, const char* message, const Args& ... args)
78 : RscException(StackCounter(), errorCode, String::Format(message, args...))
79{
80}
81
88template<typename... Args>
89inline RscException RscException::Create(RscError errorCode, const char* message, const Args& ... args)
90{
91 return RscException(StackCounter(), errorCode, String::Format(message, args...));
92}
93
94} // end of namespace Arp::Base::Rsc::Commons
This class serves as base class for all Arp commons exceptions.
Definition: CommonExceptionBase.hpp:24
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
static String Format(const String &format, const Args &... args)
Formats the format string using the .NET/Python syntax with the given variadic arguments.
Definition: String.inl:18
This exception class is used by RSC if any exception is thrown.
Definition: RscException.hpp:24
virtual ~RscException(void)
Default destructor.
RscException(RscException &&arg) noexcept
Default move constructor.
static RscException Create(RscError errorCode)
Creates an exception of this type.
Definition: RscException.cpp:103
RscException(const RscException &arg)
Default copy constructor.
RscException & operator=(RscException &&arg) noexcept
Default move-assignment operator.
RscException(RscError errorCode, const String &message)
Constructs a RscException.
Definition: RscException.cpp:57
RscException & operator=(const RscException &arg)
Default copy-assignment operator.
@ Create
Creates a new file. If the file already exists, it is overwritten.