PLCnext API Documentation 25.0.2.69
Public Types | Public Member Functions | Protected Member Functions | Friends | List of all members
Arp::Base::Core::Exception Class Reference

This is the base class of all Arp exception classes. More...

#include <Exception.hpp>

Inheritance diagram for Arp::Base::Core::Exception:
Inheritance graph

Public Types

using Ptr = std::unique_ptr< Exception >
 The smart pointer type of this class.
 
using TypeCode = std::underlying_type< Arp::Base::Core::ExceptionTypeId >::type
 The integral type of the type code.
 

Public Member Functions

 Exception (const Exception &arg)
 Default copy constructor.
 
 Exception (Exception &&arg) noexcept
 Default move constructor.
 
Exceptionoperator= (const Exception &arg)
 Default copy-assignment operator.
 
Exceptionoperator= (Exception &&arg) noexcept
 Default move-assignment operator.
 
virtual ~Exception (void)
 Default destructor.
 
 Exception (void)
 Constructs an empty instance of class Exception.
 
template<typename... Args>
 Exception (const char *message, Args &&... args)
 Constructs an instance of class Exception. More...
 
 Exception (const String &message)
 Constructs an instance of class Exception. More...
 
 Exception (String &&message)
 Constructs an instance of class Exception. More...
 
 Exception (const String &message, const Exception &innerException)
 Constructs an instance of class Exception. More...
 
 Exception (String &&message, const Exception &innerException)
 Constructs an instance of class Exception. More...
 
const StringGetMessage (void) const
 Gets the error message of this exception. More...
 
ExceptionTypeId GetTypeId (void) const
 Gets the type ID of this exception. More...
 
TypeCode GetTypeCode (void) const
 Gets the type code of this exception. More...
 
bool HasInnerException (void) const
 Determines if this exception has an inner exception. More...
 
const ExceptionGetInnerException (void) const
 Gets the inner exception of this exception. More...
 
String ToString (void) const
 This operation should be used for logging and returns a reasonable description of the exception cause. More...
 
virtual Exception::Ptr Clone (void) const
 This operation clones this instance polymorphically as a deep copy. More...
 
virtual String Format (bool withInnerException) const
 Formats this exception using the given indent level. More...
 
Impl & GetImpl (void)
 For internal use only.
 
const Impl & GetImpl (void) const
 

Protected Member Functions

 Exception (ExceptionTypeId typeId, String &&message)
 Used by derived exception classes. More...
 
 Exception (ExceptionTypeId typeId, const String &message)
 Used by derived exception classes. More...
 
 Exception (ExceptionTypeId typeId, String &&message, const Exception &innerException)
 Used by derived exception classes. More...
 
 Exception (ExceptionTypeId typeId, const String &message, const Exception &innerException)
 Used by derived exception classes. More...
 
 Exception (String &&message, const Exception::Ptr &innerExceptionPtr)
 DEPRECATED. More...
 
String Format (int indentLevel, bool withInnerException) const
 DEPRECATED. More...
 
virtual uint32 GetTypeCodeInternal (void) const
 DEPRECATED. More...
 

Friends

ARP_EXPORT std::ostream & operator<< (std::ostream &os, const Exception &arg)
 Makes the Exception class formattable. More...
 

Detailed Description

This is the base class of all Arp exception classes.

This class does not provide a stack-trace. To avoid this issue, derive any custom exception class from Arp::System::Commons::Exceptions::CommonException

Constructor & Destructor Documentation

◆ Exception() [1/10]

template<typename... Args>
Arp::Base::Core::Exception::Exception ( const char *  message,
Args &&...  args 
)
inline

Constructs an instance of class Exception.

Parameters
messageThe error message of this exception.
argsThe arguments of the message, which are formatted into the message parameter.

◆ Exception() [2/10]

Arp::Base::Core::Exception::Exception ( const String message)
explicit

Constructs an instance of class Exception.

Parameters
messageThe error message of this exception.

◆ Exception() [3/10]

Arp::Base::Core::Exception::Exception ( String &&  message)
explicit

Constructs an instance of class Exception.

Parameters
messageThe error message of this exception.

◆ Exception() [4/10]

Arp::Base::Core::Exception::Exception ( const String message,
const Exception innerException 
)

Constructs an instance of class Exception.

Parameters
messageThe error message of this exception.
innerExceptionThe inner exception of this exception.

◆ Exception() [5/10]

Arp::Base::Core::Exception::Exception ( String &&  message,
const Exception innerException 
)

Constructs an instance of class Exception.

Parameters
messageThe error message of this exception.
innerExceptionThe inner exception of this exception.

◆ Exception() [6/10]

Arp::Base::Core::Exception::Exception ( ExceptionTypeId  typeId,
String &&  message 
)
protected

Used by derived exception classes.

Parameters
typeIdThe exception type ID of the derived exception.
messageThe error message of this exception.

◆ Exception() [7/10]

Arp::Base::Core::Exception::Exception ( ExceptionTypeId  typeId,
const String message 
)
protected

Used by derived exception classes.

Parameters
typeIdThe exception type ID of the derived exception.
messageThe error message of this exception.

◆ Exception() [8/10]

Arp::Base::Core::Exception::Exception ( ExceptionTypeId  typeId,
String &&  message,
const Exception innerException 
)
protected

Used by derived exception classes.

Parameters
typeIdThe exception type ID of the derived exception.
messageThe error message of this exception.
innerExceptionThe inner exception of this exception.

◆ Exception() [9/10]

Arp::Base::Core::Exception::Exception ( ExceptionTypeId  typeId,
const String message,
const Exception innerException 
)
protected

Used by derived exception classes.

Parameters
typeIdThe exception type ID of the derived exception.
messageThe error message of this exception.
innerExceptionThe inner exception of this exception.

◆ Exception() [10/10]

Arp::Base::Core::Exception::Exception ( String &&  message,
const Exception::Ptr innerExceptionPtr 
)
protected

DEPRECATED.

Use the protected constructor 'Exception(ExceptionTypeId typeId, String&& message, const Exception& innerException)' instead to provide the 'typeId' of the derived exception.

Member Function Documentation

◆ Clone()

Exception::Ptr Arp::Exception::Clone ( void  ) const
virtual

This operation clones this instance polymorphically as a deep copy.

Never forget to override this operation in any derived exception class.

Never ever forget to override this operation in any derived exception class.

Reimplemented in Arp::Base::Commons::Exceptions::ArgumentException, Arp::Base::Commons::Exceptions::ArgumentNullException, Arp::Base::Commons::Exceptions::ArgumentOutOfRangeException, Arp::Base::Commons::Exceptions::InvalidCastException, Arp::Base::Commons::Exceptions::InvalidOperationException, Arp::Base::Commons::Exceptions::Io::EndOfStreamException, Arp::Base::Commons::Exceptions::Io::IoException, Arp::Base::Commons::Exceptions::Io::PathNotExistException, Arp::Base::Commons::Exceptions::NotAuthorizedException, Arp::Base::Commons::Exceptions::NotImplementedException, Arp::Base::Commons::Exceptions::NotSupportedException, Arp::Base::Rsc::Commons::RscException, Arp::System::Commons::IndexOutOfRangeException, Arp::System::Commons::InvalidConfigException, Arp::System::Commons::InvalidDataConnectionException, Arp::System::Commons::InvalidFormatException, Arp::System::Commons::Io::AccessDeniedException, Arp::System::Commons::Io::AlreadyExistsException, Arp::System::Commons::Io::EndOfStreamException, Arp::System::Commons::Io::InvalidPathException, Arp::System::Commons::Io::IoException, Arp::System::Commons::Io::NotExistException, Arp::System::Commons::Io::OutOfSpaceException, Arp::System::Commons::JsonException, Arp::System::Commons::KeyNotFoundException, Arp::System::Commons::LicenseException, Arp::System::Commons::ObjectDisposedException, Arp::System::Commons::OutOfMemoryException, Arp::System::Commons::ParseException, Arp::System::Commons::Plc::DivisionByZeroException, Arp::System::Commons::Plc::IndexOutOfRangeException, Arp::System::Commons::Plc::PlcException, Arp::System::Commons::Plc::StackOverflowException, Arp::System::Commons::Plc::StringException, Arp::System::Commons::ThreadInterruptException, Arp::System::Commons::TimeoutException, Arp::System::Commons::XmlException, and Arp::System::Commons::XmlValidationException.

◆ Format() [1/2]

String Arp::Base::Core::Exception::Format ( bool  withInnerException) const
virtual

Formats this exception using the given indent level.

Parameters
withInnerExceptionIf true the inner exception (if any) should be formatted into the resulting string as well.

This operation might be overridden in derived classes to specialize the format when calling ToString.

Reimplemented in Arp::Base::Commons::Exceptions::CommonExceptionBase, and Arp::System::Commons::CommonException.

◆ Format() [2/2]

String Arp::Exception::Format ( int  indentLevel,
bool  withInnerException 
) const
protected

DEPRECATED.

Override this operation to apply special formatting of the exception.

Override 'String Exception::Format(bool withInnerException)const' instead.

◆ GetInnerException()

const Exception & Arp::Base::Core::Exception::GetInnerException ( void  ) const

Gets the inner exception of this exception.

Returns
The inner exception of this exception.

◆ GetMessage()

const String & Arp::Base::Core::Exception::GetMessage ( void  ) const

Gets the error message of this exception.

Returns
The error message of this exception.

◆ GetTypeCode()

Exception::TypeCode Arp::Base::Core::Exception::GetTypeCode ( void  ) const

Gets the type code of this exception.

Returns
The type code of this exception is the integral value of its ExceptionTypeId.

Returns 0 for class Exception and any value of enum ExceptionTypeId for any derived class.

◆ GetTypeCodeInternal()

uint32 Arp::Exception::GetTypeCodeInternal ( void  ) const
protectedvirtual

DEPRECATED.

Override this operation in derived classes to provide a specialized type code.

Remove the override of this operation, it's not required any more. The type code is determined by the 'typeId' which is passed to one of the protected constructors.

This default implementation returns 0.

◆ GetTypeId()

ExceptionTypeId Arp::Base::Core::Exception::GetTypeId ( void  ) const

Gets the type ID of this exception.

Returns
The ExceptionTypeId of this exception.

Returns ExceptionTypeId::Exception for class Exception and any value of enum ExceptionTypeId for any derived class.

◆ HasInnerException()

bool Arp::Base::Core::Exception::HasInnerException ( void  ) const

Determines if this exception has an inner exception.

Returns
true if this exception has an inner exception, otherwise false.

◆ ToString()

String Arp::Exception::ToString ( void  ) const

This operation should be used for logging and returns a reasonable description of the exception cause.

This operation should be used for logging and returns a reasonable description of the exception cause.

This operation might be overridden in any derived exception class to apply more infos like stack-trace, filename or line number. The default implementation just returns the message which was passed to the constructor and the exception string of the inner exception if any exist.

This operation might be overridden in any derived exception class to apply more infos like stacktracing, filename or line number. The default implementation just returns the message which was passed to the constructor and the exception string of the inner exception if any exist.

Friends And Related Function Documentation

◆ operator<<

ARP_EXPORT std::ostream & operator<< ( std::ostream &  os,
const Exception arg 
)
friend

Makes the Exception class formattable.

Parameters
osThe stream to write the exception to.
argThe exception to write.
Returns
The as argument passed stream.

The documentation for this class was generated from the following files: