Cross-Platform C++

ot
class Exception

#include "ot/base/Exception.h"

ot::auxil::CommandLineException ot::InterruptedException ot::io::IOException ot::net::MalformedURLException ot::RuntimeException ot::sax::SAXException ot::util::InvalidDateException ot::io::AtomicReadException ot::io::CharacterCodingException ot::io::ExistingFileException ot::io::FileNotFoundException ot::io::InterruptedIOException ot::io::UnsupportedEncodingException ot::net::ProtocolException ot::net::SocketException ot::net::UnknownHostException ot::IllegalArgumentException ot::IllegalCharacterException ot::IllegalMonitorStateException ot::IllegalStateException ot::IllegalThreadStateException ot::NullPointerException ot::OSException ot::UnsupportedOperationException ot::sax::SAXNotRecognizedException ot::sax::SAXNotSupportedException ot::sax::SAXParseException Base class for all exceptions thrown from the OpenTop library. Functions within OpenTop rarely throw an exception of type Exception, but usually throw one of the many derivatives such as net::SocketException when a socket error occurs. However, applications may catch exceptions of type Exception and extract a meaningful error message by calling the toString() member function.

    try
    {
        //  open a FileInputStream (may throw a FileNotFoundException)
        RefPtr<FileInputStream> rpFIS = new FileInputStream(OT_T("test.txt"));
    }
    catch(Exception& e)
    {
        std::err << StringUtils::ToAscii(e.toString()) << std::endl;
    }




Constructor/Destructor Summary
Exception()
         Constructs an Exception without any additional message description.
Exception(const String& message)
         Constructs an Exception with a description message.
~Exception()
         Virtual destructor.

Method Summary
 String getDescription() const
         Returns a description of this Exception type.
 virtual String getExceptionType() const
         Returns the class name as a String.
 virtual String getLocalizedDescription() const
         Returns a localized description of the Exception type or, if a native language translation is unavailable, an empty string.
 virtual String getMessage() const
         Returns the message text for this Exception.
protected  void setMessage(const String& message)
         Sets the message text for an Exception.
 virtual String toString() const
         Returns a string representation of this Exception.

Constructor/Destructor Detail

Exception

 Exception()
Constructs an Exception without any additional message description.


Exception

 Exception(const String& message)
Constructs an Exception with a description message.

Parameters:
message - a String providing further information about the exception

~Exception

virtual ~Exception()
Virtual destructor. Ensures that derived class' destructor will be called if a pointer to an Exception is ever deleted. Note, however, that OpenTop always throws exceptions by value and catches them by reference.


Method Detail

getDescription

String getDescription() const
Returns a description of this Exception type. If getLocalizedDescription() returns a non-empty string, then it is returned, otherwise the exception class name returned from getExceptionType() is returned.


getExceptionType

virtual String getExceptionType() const
Returns the class name as a String. This method should be overridden in all derived classes to return the name of the derived class.

See also:
getDescription()

getLocalizedDescription

virtual String getLocalizedDescription() const
Returns a localized description of the Exception type or, if a native language translation is unavailable, an empty string. The base class implementation always returns an empty string.

See also:
getDescription()

getMessage

virtual String getMessage() const
Returns the message text for this Exception.


setMessage

protected void setMessage(const String& message)
Sets the message text for an Exception. Intended to be called by the constructors of derived exception classes.

Parameters:
message - the message text for the exception

toString

virtual String toString() const
Returns a string representation of this Exception. If this Exception has a non-empty message text, the return value is made up as follows:- If the message text is empty then toString() returns the same value as getDescription().



Cross-Platform C++

Found a bug or missing feature? Please email us at support@elcel.com

Copyright © 2000-2003 ElCel Technology   Trademark Acknowledgements