PLCnext API Documentation 23.6.0.37
CommonException.hpp
1
2//
3// Copyright PHOENIX CONTACT Electronics GmbH
4//
6#pragma once
8#include "Arp/System/Core/Exception.hpp"
9#include "Arp/System/Commons/Exceptions/ExceptionTypeId.hpp"
10#include "Arp/System/Commons/Runtime/StackTrace.hpp"
11
12namespace Arp { namespace System { namespace Commons
13{
14
15using namespace Arp::System::Commons::Runtime;
16
19{
20protected: // construction/destruction
21 CommonException(ExceptionTypeId typeId, const String& message, int skipStackTraceDepth = 0);
22 CommonException(ExceptionTypeId typeId, String&& message, int skipStackTraceDepth = 0);
23 CommonException(ExceptionTypeId typeId, const String& message, const Exception& innerException, int skipStackTraceDepth = 0);
24 CommonException(ExceptionTypeId typeId, String&& message, Exception&& innerException, int skipStackTraceDepth = 0);
25 CommonException(ExceptionTypeId typeId, String&& message, Exception::Ptr&& innerExceptionPtr, int skipStackTraceDepth = 0);
26 CommonException(const CommonException& arg) = default;
27 CommonException(CommonException&& arg)noexcept = default;
28 virtual ~CommonException(void) = default;
29
30public: // getter
31 ExceptionTypeId GetTypeId(void)const;
32
33protected: // overridden operations
34 String Format(int indentLevel, bool withInnerException)const override;
35 uint32 GetTypeCodeInternal(void)const override;
36
37private: // deleted methods
38 CommonException& operator=(const CommonException& arg) = delete;
39
40private: // fields
41 StackTrace stackTrace;
42 ExceptionTypeId typeId;
43};
44
46// inline methods of class Exception
48inline CommonException::CommonException(ExceptionTypeId typeIdArg, const String& messageArg, int skipStackTraceDepth)
49 : Exception(messageArg)
50 , stackTrace(std::move(StackTrace::GetCurrent(skipStackTraceDepth)))
51 , typeId(typeIdArg)
52{
53}
54
56inline CommonException::CommonException(ExceptionTypeId typeIdArg, String&& messageArg, int skipStackTraceDepth)
57 : Exception(std::move(messageArg))
58 , stackTrace(std::move(StackTrace::GetCurrent(skipStackTraceDepth)))
59 , typeId(typeIdArg)
60{
61}
62
64inline CommonException::CommonException(ExceptionTypeId typeIdArg, const String& messageArg, const Exception& innerException, int skipStackTraceDepth)
65 : Exception(messageArg, innerException)
66 , stackTrace(std::move(StackTrace::GetCurrent(skipStackTraceDepth)))
67 , typeId(typeIdArg)
68{
69}
70
72inline CommonException::CommonException(ExceptionTypeId typeIdArg, String&& messageArg, Exception&& innerException, int skipStackTraceDepth)
73 : Exception(std::move(messageArg), std::move(innerException))
74 , stackTrace(std::move(StackTrace::GetCurrent(skipStackTraceDepth)))
75 , typeId(typeIdArg)
76{
77}
78
80inline CommonException::CommonException(ExceptionTypeId typeIdArg, String&& messageArg, Exception::Ptr&& innerExceptionPtrArg, int skipStackTraceDepth)
81 : Exception(std::move(messageArg), std::move(innerExceptionPtrArg))
82 , stackTrace(std::move(StackTrace::GetCurrent(skipStackTraceDepth)))
83 , typeId(typeIdArg)
84{
85}
86
90{
91 return this->typeId;
92}
93
94}}} // 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
ExceptionTypeId GetTypeId(void) const
Returns the ExceptionTypeId of this exception.
Definition: CommonException.hpp:89
CommonException(ExceptionTypeId typeId, const String &message, int skipStackTraceDepth=0)
Constructs an CommonException instance.
Definition: CommonException.hpp:48
String Format(int indentLevel, bool withInnerException) const override
Formats this exception using the given indent level.
uint32 GetTypeCodeInternal(void) const override
Get the type code of this exception. Must be overridden by derived classes.
Definition: StackTrace.hpp:14
std::uint32_t uint32
The Arp unsigned integer type of 4 byte size.
Definition: PrimitiveTypes.hpp:36
@ System
System components used by the System, Device, Plc or Io domains.
Namespace for high level API for controlling processes, shared libraries, etc.
Definition: Process.hpp:15
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