activemq-cpp-3.9.5
decaf::lang::Throwable Class Referenceabstract

This class represents an error that has occurred. More...

#include <src/main/decaf/lang/Throwable.h>

Inheritance diagram for decaf::lang::Throwable:

Public Member Functions

 Throwable ()
 
virtual ~Throwable () throw ()
 
virtual std::string getMessage () const =0
 Gets the cause of the error, if no message was provided to the instance of this interface but a cause was then the value cause.getMessage is then returned.
 
virtual const std::exception * getCause () const =0
 Gets the exception that caused this one to be thrown, this allows for chaining of exceptions in the case of a method that throws only a particular exception but wishes to allow for the real causal exception to be passed only in case the caller knows about that type of exception and wishes to respond to it.
 
virtual void initCause (const std::exception *cause)=0
 Initializes the contained cause exception with the one given.
 
virtual void setMark (const char *file, const int lineNumber)=0
 Adds a file/line number to the stack trace.
 
virtual Throwableclone () const =0
 Clones this exception.
 
virtual std::vector< std::pair< std::string, int > > getStackTrace () const =0
 Provides the stack trace for every point where this exception was caught, marked, and rethrown.
 
virtual void printStackTrace () const =0
 Prints the stack trace to std::err.
 
virtual void printStackTrace (std::ostream &stream) const =0
 Prints the stack trace to the given output stream.
 
virtual std::string getStackTraceString () const =0
 Gets the stack trace as one contiguous string.
 

Detailed Description

This class represents an error that has occurred.

All Exceptions in the Decaf library should extend from this or from the Exception class in order to ensure that all Decaf Exceptions are interchangeable with the std::exception class.

Throwable can wrap another Throwable as the cause if the error being thrown. The user can inspect the cause by calling getCause, the pointer returned is the property of the Throwable instance and will be deleted when it is deleted or goes out of scope.

Since
1.0

Constructor & Destructor Documentation

◆ Throwable()

decaf::lang::Throwable::Throwable ( )

Referenced by clone().

◆ ~Throwable()

virtual decaf::lang::Throwable::~Throwable ( )
throw ( )
virtual

Member Function Documentation

◆ clone()

virtual Throwable * decaf::lang::Throwable::clone ( ) const
pure virtual

Clones this exception.

This is useful for cases where you need to preserve the type of the original exception as well as the message. All subclasses should override.

Returns
Copy of this Exception object

Implemented in activemq::exceptions::ActiveMQException, activemq::exceptions::BrokerException, activemq::exceptions::ConnectionFailedException, decaf::internal::net::ssl::openssl::OpenSSLSocketException, decaf::io::EOFException, decaf::io::InterruptedIOException, decaf::io::IOException, decaf::io::UnsupportedEncodingException, decaf::io::UTFDataFormatException, decaf::lang::Exception, decaf::lang::exceptions::ArrayIndexOutOfBoundsException, decaf::lang::exceptions::ClassCastException, decaf::lang::exceptions::CloneNotSupportedException, decaf::lang::exceptions::IllegalArgumentException, decaf::lang::exceptions::IllegalMonitorStateException, decaf::lang::exceptions::IllegalStateException, decaf::lang::exceptions::IllegalThreadStateException, decaf::lang::exceptions::IndexOutOfBoundsException, decaf::lang::exceptions::InterruptedException, decaf::lang::exceptions::InvalidStateException, decaf::lang::exceptions::NegativeArraySizeException, decaf::lang::exceptions::NullPointerException, decaf::lang::exceptions::NumberFormatException, decaf::lang::exceptions::OutOfMemoryError, decaf::lang::exceptions::RuntimeException, decaf::lang::exceptions::SecurityException, decaf::lang::exceptions::StringIndexOutOfBoundsException, decaf::lang::exceptions::UnsupportedOperationException, decaf::net::BindException, decaf::net::ConnectException, decaf::net::HttpRetryException, decaf::net::MalformedURLException, decaf::net::NoRouteToHostException, decaf::net::PortUnreachableException, decaf::net::ProtocolException, decaf::net::SocketException, decaf::net::SocketTimeoutException, decaf::net::UnknownHostException, decaf::net::UnknownServiceException, decaf::net::URISyntaxException, decaf::nio::BufferOverflowException, decaf::nio::BufferUnderflowException, decaf::nio::InvalidMarkException, decaf::nio::ReadOnlyBufferException, decaf::security::cert::CertificateEncodingException, decaf::security::cert::CertificateException, decaf::security::cert::CertificateExpiredException, decaf::security::cert::CertificateNotYetValidException, decaf::security::cert::CertificateParsingException, decaf::security::DigestException, decaf::security::GeneralSecurityException, decaf::security::InvalidKeyException, decaf::security::KeyException, decaf::security::KeyManagementException, decaf::security::NoSuchAlgorithmException, decaf::security::NoSuchProviderException, decaf::security::ProviderException, decaf::security::SignatureException, decaf::util::concurrent::BrokenBarrierException, decaf::util::concurrent::CancellationException, decaf::util::concurrent::ExecutionException, decaf::util::concurrent::RejectedExecutionException, decaf::util::concurrent::TimeoutException, decaf::util::ConcurrentModificationException, decaf::util::NoSuchElementException, decaf::util::zip::DataFormatException, and decaf::util::zip::ZipException.

References clone(), const, and Throwable().

Referenced by clone().

◆ getCause()

virtual const std::exception * decaf::lang::Throwable::getCause ( ) const
pure virtual

Gets the exception that caused this one to be thrown, this allows for chaining of exceptions in the case of a method that throws only a particular exception but wishes to allow for the real causal exception to be passed only in case the caller knows about that type of exception and wishes to respond to it.

Returns
a const pointer reference to the causal exception, if there was no cause associated with this exception then NULL is returned.

Implemented in decaf::lang::Exception.

References const, and getCause().

Referenced by getCause().

◆ getMessage()

virtual std::string decaf::lang::Throwable::getMessage ( ) const
pure virtual

Gets the cause of the error, if no message was provided to the instance of this interface but a cause was then the value cause.getMessage is then returned.

Returns
string errors message

Implemented in decaf::lang::Exception.

References const, and getMessage().

Referenced by getMessage().

◆ getStackTrace()

virtual std::vector< std::pair< std::string, int > > decaf::lang::Throwable::getStackTrace ( ) const
pure virtual

Provides the stack trace for every point where this exception was caught, marked, and rethrown.

Returns
vector containing stack trace strings

Implemented in decaf::lang::Exception.

References const, and getStackTrace().

Referenced by getStackTrace().

◆ getStackTraceString()

virtual std::string decaf::lang::Throwable::getStackTraceString ( ) const
pure virtual

Gets the stack trace as one contiguous string.

Returns
string with formatted stack trace data

Implemented in decaf::lang::Exception.

References const, and getStackTraceString().

Referenced by getStackTraceString().

◆ initCause()

virtual void decaf::lang::Throwable::initCause ( const std::exception * cause)
pure virtual

Initializes the contained cause exception with the one given.

A copy is made to avoid ownership issues.

Parameters
causeThe exception that was the cause of this one.

Implemented in decaf::lang::Exception.

References const, and initCause().

Referenced by initCause().

◆ printStackTrace() [1/2]

virtual void decaf::lang::Throwable::printStackTrace ( ) const
pure virtual

Prints the stack trace to std::err.

Implemented in decaf::lang::Exception.

References const, and printStackTrace().

Referenced by printStackTrace(), and printStackTrace().

◆ printStackTrace() [2/2]

virtual void decaf::lang::Throwable::printStackTrace ( std::ostream & stream) const
pure virtual

Prints the stack trace to the given output stream.

Parameters
streamthe target output stream.

Implemented in decaf::lang::Exception.

References const, and printStackTrace().

◆ setMark()

virtual void decaf::lang::Throwable::setMark ( const char * file,
const int lineNumber )
pure virtual

Adds a file/line number to the stack trace.

Parameters
fileThe name of the file calling this method (use FILE).
lineNumberThe line number in the calling file (use LINE).

Implemented in decaf::lang::Exception.

References const, and setMark().

Referenced by setMark().


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