PLCnext API Documentation  21.0.0.35466
XmlException.hpp
1 //
3 // Copyright PHOENIX CONTACT Electronics GmbH
4 //
6 #pragma once
7 #include "Arp/System/Core/Arp.h"
8 #include "Arp/System/Commons/Exceptions/CommonException.hpp"
9 
10 namespace Arp { namespace System { namespace Commons
11 {
12 
15 {
16 public: // construction/destruction
17  template<typename... Args>
18  XmlException(const char* message, const Args& ... args);
19  XmlException(const String& message);
20  XmlException(String&& message);
21  XmlException(const String& message, const Exception& innerException);
22  XmlException(String&& message, Exception&& innerException);
23  XmlException(const XmlException& arg) = default;
24  XmlException(XmlException&& arg) = default;
25  virtual ~XmlException(void) = default;
26 
27 public: // static factory methods
28  static XmlException Create(void);
29  static XmlException Create(const Exception& innerException);
30  template<typename... Args>
31  static XmlException Create(const char* filename, long lineNumber, const char* message, const Args& ... args);
32 
33 protected: // overridden operations
34  Exception::Ptr Clone(void)const override;
35 
36 private: // deleted methods
37  XmlException& operator=(const XmlException& arg) = delete;
38 
39 private:
40  static const char* const defaultMessage;
41  static const char* const fileLineMessage;
42 };
43 
45 // inline methods of class XmlException
46 
48 template<typename... Args>
49 inline XmlException::XmlException(const char* message, const Args& ... args)
50  : CommonException(ExceptionTypeId::Xml, String::Format(message, args...))
51 {
52 }
53 
55 inline XmlException::XmlException(const String& message)
56  : CommonException(ExceptionTypeId::Xml, message)
57 {
58 }
59 
62  : CommonException(ExceptionTypeId::Xml, std::move(message))
63 {
64 }
65 
67 inline XmlException::XmlException(const String& message, const Exception& innerException)
68  : CommonException(ExceptionTypeId::Xml, message, innerException)
69 {
70 }
71 
73 inline XmlException::XmlException(String&& message, Exception&& innerException)
74  : CommonException(ExceptionTypeId::Xml, std::move(message), std::move(innerException))
75 {
76 }
77 
80 {
81  return XmlException(defaultMessage);
82 }
83 
85 inline XmlException XmlException::Create(const Exception& innerException)
86 {
87  return XmlException(String(defaultMessage), innerException);
88 }
89 
90 template<typename... Args>
91 inline XmlException XmlException::Create(const char* filename, long lineNumber, const char* message, const Args& ... args)
92 {
93  return XmlException(String::Format(fileLineMessage, String::Format(message, args...), filename, lineNumber));
94 }
95 
96 }}} // end of namesapce Arp::System::Commons
Exception::Ptr Clone(void) const override
Clones this instance.
This is the base class of common exception classes.
Definition: CommonException.hpp:18
String Format(int indentLevel, bool withInnerException) const override
Formats this exception using the given indent level.
Namespace of the C++ standard library
static XmlException Create(void)
Creates an XmlException instance using a default message text.
Definition: XmlException.hpp:79
std::shared_ptr< Exception > Ptr
The smart pointer tpye of this class.
Definition: Exception.hpp:19
ExceptionTypeId
Specifies the type id of any exception derived by <see cref="CommonException".
Definition: ExceptionTypeId.hpp:14
static SelfType Format(const SelfType &format, const Args &... args)
Formats the format string using the .NET/Python syntax with the given variadic arguments.
Definition: BasicString.hxx:1482
Root namespace for the PLCnext API
This exception is used for xml parsing errors.
Definition: XmlException.hpp:14
XmlException(const char *message, const Args &... args)
Constructs an XmlException instance.
Definition: XmlException.hpp:49
System components used by the System, Device, Plc or Io domains.
This is the base class of all Arp exception classes.
Definition: Exception.hpp:15