PLCnext API Documentation 24.0.0.71
RscException.hpp
1
2//
3// Copyright PHOENIX CONTACT Electronics GmbH
4//
6#pragma once
8#include "Arp/System/Commons/Exceptions/CommonException.hpp"
9#include "Arp/System/Rsc/Services/RscErrors.h"
10
11namespace Arp { namespace System { namespace Rsc { namespace Services
12{
13
15class RscException : public Arp::System::Commons::CommonException
16{
17public: // usings
19
20public: // construction/destruction
21 template<typename... Args>
22 RscException(int rscErrorCode, const char* message, const Args& ... args);
23 RscException(int rscErrorCode, const String& message);
24 RscException(int rscErrorCode, String&& message);
25 RscException(int rscErrorCode, const String& message, const Exception& innerException);
26 RscException(int rscErrorCode, String&& message, Exception&& innerException);
27 RscException(const RscException& arg) = default;
28 RscException(RscException&& arg) = default;
29 virtual ~RscException(void) = default;
30
31public: // setter/getter operations
32 RscErrors GetErrorCode(void) const;
33
34protected: // overridden operations
35 Exception::Ptr Clone(void)const override;
36 String Format(int indentLevel, bool withInnerException)const override;
37
38
39public: // static factory methods
40 static RscException Create(RscErrors rscErrorCode = DefaultError);
41 static RscException Create(const Exception& innerExeption, RscErrors rscErrorCode = DefaultError);
42
43private: // deleted methods
44 RscException& operator=(const RscException& arg) = delete;
45
46private: // fields
47 RscErrors rscError = DefaultError;
48
49public: // static fields
50 static const RscErrors DefaultError = RscErrors::InternalError;
51 static const String DefaultMessage;
52};
53
55// inline methods of class RscException
56template<typename... Args>
57inline RscException::RscException(int rscErrorCode, const char* message, const Args& ... args)
58 : CommonException(ExceptionTypeId::Rsc, String::Format(message, args...))
59 , rscError((RscErrors)rscErrorCode)
60{
61}
62
63inline RscException::RscException(int rscErrorCode, const String& message)
64 : CommonException(ExceptionTypeId::Rsc, message)
65 , rscError((RscErrors)rscErrorCode)
66{
67}
68
69inline RscException::RscException(int rscErrorCode, String&& message)
70 : CommonException(ExceptionTypeId::Rsc, std::move(message))
71 , rscError((RscErrors)rscErrorCode)
72{
73}
74
75inline RscException::RscException(int rscErrorCode, const String& message, const Exception& innerException)
76 : CommonException(ExceptionTypeId::Rsc, message, innerException)
77 , rscError((RscErrors)rscErrorCode)
78{
79}
80
81inline RscException::RscException(int rscErrorCode, String&& message, Exception&& innerException)
82 : CommonException(ExceptionTypeId::Rsc, std::move(message), std::move(innerException))
83 , rscError((RscErrors)rscErrorCode)
84{
85}
86
87inline RscErrors RscException::GetErrorCode(void)const
88{
89 return this->rscError;
90}
91
92inline RscException RscException::Create(RscErrors rscErrorCode)
93{
94 return RscException((int)rscErrorCode, DefaultMessage);
95}
96
97}}}} // end of namespace Arp::System::Rsc::Services
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
Arp::BasicString< char8 > String
The Arp String class.
Definition: TypeSystem.h:27
@ System
System components used by the System, Device, Plc or Io domains.
@ 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