PLCnext API Documentation  21.0.0.35466
AlreadyExistsException.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/Io/IoException.hpp"
9 
10 namespace Arp { namespace System { namespace Commons { namespace Io
11 {
12 
15 {
16 public: // construction/destruction
17  template<typename... Args>
18  AlreadyExistsException(const char* message, const Args& ... args);
19  AlreadyExistsException(const String& message);
20  AlreadyExistsException(String&& message);
21  AlreadyExistsException(const String& message, const Exception& innerException);
22  AlreadyExistsException(String&& message, Exception&& innerException);
23  AlreadyExistsException(const AlreadyExistsException& arg) = default;
24  AlreadyExistsException(AlreadyExistsException&& arg) = default;
25  virtual ~AlreadyExistsException(void) = default;
26 
27 public: // static factory methods
28  static AlreadyExistsException Create(const String& path);
29  static AlreadyExistsException Create(const String& path, const Exception& innerException);
30 
31 protected: // overridden operations
32  Exception::Ptr Clone(void)const override;
33 
34 private: // deleted methods
35  AlreadyExistsException& operator=(const AlreadyExistsException& arg) = delete;
36 
37 private:
38  static const char* const defaultMessage;
39 };
40 
42 // inline methods of class AlreadyExistsException
43 
45 template<typename... Args>
46 inline AlreadyExistsException::AlreadyExistsException(const char* message, const Args& ... args)
47  : IoException(ExceptionTypeId::IoAlreadyExists, String::Format(message, args...))
48 {
49 }
50 
53  : IoException(ExceptionTypeId::IoAlreadyExists, message)
54 {
55 }
56 
59  : IoException(ExceptionTypeId::IoAlreadyExists, std::move(message))
60 {
61 }
62 
64 inline AlreadyExistsException::AlreadyExistsException(const String& message, const Exception& innerException)
65  : IoException(ExceptionTypeId::IoAlreadyExists, message, innerException)
66 {
67 }
68 
71  : IoException(ExceptionTypeId::IoAlreadyExists, std::move(message), std::move(innerException))
72 {
73 }
74 
77 {
78  return AlreadyExistsException(defaultMessage, path);
79 }
80 
82 inline AlreadyExistsException AlreadyExistsException::Create(const String& path, const Exception& innerException)
83 {
84  return AlreadyExistsException(String::Format(defaultMessage, path), innerException);
85 }
86 
87 }}}} // end of namesapce Arp::System::Commons::Io
String Format(int indentLevel, bool withInnerException) const override
Formats this exception using the given indent level.
static AlreadyExistsException Create(const String &path)
Creates an AlreadyExistsException instance using a default message text.
Definition: AlreadyExistsException.hpp:76
Exception::Ptr Clone(void) const override
Clones this instance.
Namespace of the C++ standard library
This exception is used when a file should be created that already exists.
Definition: AlreadyExistsException.hpp:14
This is the base class of all IO exceptions.
Definition: IoException.hpp:14
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
AlreadyExistsException(const char *message, const Args &... args)
Constructs an AlreadyExistsException instance.
Definition: AlreadyExistsException.hpp:46
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