Jive reference manual
List of all members | Public Member Functions
jem::Throwable Class Reference

Provides a single superclass for all exceptions in Jem. More...

#include <jem/base/Throwable.h>

Inheritance diagram for jem::Throwable:
Inheritance graph

Public Member Functions

 Throwable (const String &place=String(), Const String &msg=String())
 Creates a new Throwable instance. More...
 
 Throwable (const Throwable &rhs)
 Creates a copy of another Throwable instance. More...
 
 ~Throwable ()
 Destructor. More...
 
virtual String where () const
 Returns a string describing the context in which this Throwable was thrown. More...
 
virtual String what () const
 Returns a string describing why this Throwable was thrown. More...
 
virtual String name () const
 Returns the class name of this exception. More...
 

Detailed Description

All objects thrown by jem are instances of the Throwable class or one of its derived classes. This means that the try-block

try
{
...
}
catch ( const Throwable& e )
{
...
}

will catch all exceptions thrown by jem.

By convention, classes derived from the Throwable class provide a constructor that takes two strings as its arguments: one that describes the context in which the exception occured, and one that describes the cause of the exception. The first string is typically the name of a function and can be generated automatically by using the macro JEM_FUNC. This macro expands to a static, null-terminated character array containing the name of the current function. Example:

double Vector::get ( int i ) const
{
if ( i < 0 && i >= size() )
{
throw IllegalIndexException ( JEM_FUNC, "illegal array index" );
}
return elements[i];
}

Here, the macro JEM_FUNC will expand to `Vector::get( int i ) const', or something similar.

Constructor & Destructor Documentation

jem::Throwable::Throwable ( const String place = String(),
Const String msg = String() 
)
explicit

Constructs a Throwable instance with a given context and message string.

Parameters
place- a string describing the context in which this Throwable was thrown. The macro JEM_FUNC can be used to obtain the name of the current function.
msg- a string describing why this Throwable was thrown.
Postcondition
this->where() == place &&
this->what() == msg
jem::Throwable::Throwable ( const Throwable rhs)

Creates a copy of the Throwable rhs.

Parameters
rhs- the Throwable to be copied.
Postcondition
this->where() == rhs.where() &&
this->what() == rhs.what()
jem::Throwable::~Throwable ( )

Deallocates all privately allocated memory.

Member Function Documentation

virtual String jem::Throwable::where ( ) const
virtual

Returns a string describing the context in which this Throwable was thrown. The default implementation provided by the Throwable class simply returns the string that was passed as the first argument in the constructor.

Returns
A string describing where this Throwable was thrown.
virtual String jem::Throwable::what ( ) const
virtual

Returns a string describing why this Throwable object was thrown. The default implementation provided by the Throwable class simply returns the String that was passed as the second argument in the constructor.

Returns
A string describing why this Throwable was thrown.
virtual String jem::Throwable::name ( ) const
virtual

Returns the full class name – including namespaces – of this Throwable instance. This function should be overriden by derived classes. For instance, a class named flip::FlopException should return the string "flip::FlopException".

Returns
A string describing the class name of this object.

Reimplemented in jive::fem::MeshCutter::Exception, jive::solver::SolverException, jem::util::PropertyException, jem::RuntimeException, jem::Exception, jem::ParseException, jem::io::IOException, jive::solver::IterativeSolverException, jive::model::ActionException, jive::util::ItemIDException, jem::io::CancelledIOException, jem::gl::GLException, jem::MemoryError, jem::hdf5::H5Exception, jem::IllegalIndexException, jem::xml::ParserException, jem::gl::TextureException, jem::mp::AbortException, jem::Error, jive::fem::InvalidBlocksException, jive::mp::InvalidBordersException, jive::util::TableException, jem::gl::DisplayException, jem::io::EOFException, jem::io::FileOpenException, jem::io::IOverflowException, jem::io::SerializationException, jem::io::SyncFailedException, jem::io::ZipException, jem::numeric::FuncException, jem::CancelledException, jem::mp::DriverException, jem::mp::MPException, jem::util::DateException, jem::ArithmeticException, jem::ClassCastException, jem::IllegalArgumentException, jem::IllegalInputException, jem::IllegalOperationException, jem::InstantiationException, jem::OutOfMemoryException, jem::PrecheckException, jem::RangeException, jem::SystemException, jem::util::EmptySequenceException, jem::AssertException, and jem::NullPointerException.