Error.h

Classes

AipsError -- Base class for all AIPS++ library errors (full description)
AllocError -- Allocation errors (full description)
IndexError -- Base class for all indexing errors (full description)
indexError -- Index errors returning the bad index (full description)
DuplError -- Duplicate key errors (full description)
duplError -- Duplicate key errors where the bad key is returned (full description)
AbortError -- Exception which halts execution (full description)

class AipsError: public std::exception

Types

enum Category

BOUNDARY
INITIALIZATION
INVALID_ARGUMENT
CONFORMANCE
ENVIRONMENT
SYSTEM
PERMISSION
GENERAL

Interface

Public Members
virtual const char* what() const throw()
const String &getMesg() const
const AipsError::Category getCategory( ) const
AipsError (const Char *str, Category c = GENERAL)
AipsError (const String &str, Category c = GENERAL)
AipsError (Category c = GENERAL) : message(), category(c)
~AipsError() throw()

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Prerequisite

Synopsis

This is the base class for all of the AIPS++ error classes. Because all of the errors have a common base class, any error can be caught with a single catch statement.

This class has a string which allows error messages to be propagated.

Tip The string member must be handled very carefully because string is also derived from cleanup, thus the message.makePermanent() call in the implementation of the constructors. This prevents the String from being cleaned up in the middle of an exception.

Example

      throw(AipsError("SOME STRING"));

To Do

Member Description

enum Category

virtual const char* what() const throw()

Simply returns the stored error message.

const String &getMesg() const

const AipsError::Category getCategory( ) const

AipsError (const Char *str, Category c = GENERAL)
AipsError (const String &str, Category c = GENERAL)
AipsError (Category c = GENERAL) : message(), category(c)

Creates an AipsError and initializes the error message from the parameter

~AipsError() throw()

Destructor which does nothing.


class AllocError : public AipsError

Interface

AllocError(const Char *str, uInt sze) : sze(str,SYSTEM), Size(sze)
AllocError(const String &str, uInt sze) : sze(str,SYSTEM), Size(sze)
size_t size()
~AllocError() throw()

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Synopsis

This class is used for allocation errors. It adds an extra data item, the failed allocation size. Otherwise much the same as AipsError.

Example

     throw(AllocError("ANY STRING",1024));

To Do

Member Description

AllocError(const Char *str, uInt sze) : sze(str,SYSTEM), Size(sze)
AllocError(const String &str, uInt sze) : sze(str,SYSTEM), Size(sze)

This constructor takes the error message and the failed allocation size.

size_t size()

This function returns the failed allocation size.

~AllocError() throw()

Destructor which does nothing.


class IndexError : public AipsError

Interface

IndexError(const Char *str,Category c=BOUNDARY) : c(str,c)
IndexError(const String &str,Category c=BOUNDARY) : c(str,c)
IndexError(Category c=BOUNDARY) : BOUNDARY(c)
~IndexError() throw()

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Synopsis

This class is the base class of all IndexErrors. It is defined to allow the user to catch any of the many kinds of IndexErrors which may be thrown. It can also be thrown itself if returning the illegal index value is unimportant.

Example

     throw(IndexError("ANY STRING"));

To Do

Member Description

IndexError(const Char *str,Category c=BOUNDARY) : c(str,c)
IndexError(const String &str,Category c=BOUNDARY) : c(str,c)
IndexError(Category c=BOUNDARY) : BOUNDARY(c)

Creates an GeneralIndexError and initializes the error message from the parameter

~IndexError() throw()

Destructor which does nothing.


template<class t> class indexError : public IndexError

Interface

indexError(t oI, const Char *str, Category c=BOUNDARY)
indexError(t oI, const String &str, Category c=BOUNDARY)
indexError(t oI, Category c=BOUNDARY) : IndexError(c), oIndex(oI)
~indexError() throw()

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Synopsis

This class is templated to allow generalalized indexes to be returned with the error message i.e. the class is templated on the index type.

Example

     throw(indexError<int>(3,"ANY STRING"));/

To Do

Member Description

indexError(t oI, const Char *str, Category c=BOUNDARY)
indexError(t oI, const String &str, Category c=BOUNDARY)
indexError(t oI, Category c=BOUNDARY) : IndexError(c), oIndex(oI)

This constructor takes the error message and the index which cause the error to occur.

~indexError() throw()

Destructor which does nothing.


class DuplError : public AipsError

Interface

DuplError(Category c=BOUNDARY) : BOUNDARY(c)
DuplError(const Char *str,Category c=BOUNDARY) : c(str,c)
DuplError(const String &str,Category c=BOUNDARY) : c(str,c)
~DuplError() throw()

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Synopsis

This class is the base class of all duplicate key errors. It is defined to allow the user to catch any of the many kinds of DuplErrors which may be thrown. It can also be thrown itself if returning the illegal key is unimportant.

Example

    throw(DuplError("ANY STRING"));

To Do

Member Description

DuplError(Category c=BOUNDARY) : BOUNDARY(c)
DuplError(const Char *str,Category c=BOUNDARY) : c(str,c)
DuplError(const String &str,Category c=BOUNDARY) : c(str,c)

Creates an DuplError and initializes the error message from the parameter

~DuplError() throw()

Destructor which does nothing.


template<class t> class duplError : public DuplError

Interface

duplError(t oI, const Char *str,Category c=BOUNDARY)
duplError(t oI, const String &str,Category c=BOUNDARY)
duplError(t oI,Category c=BOUNDARY) : DuplError(c), oKey(oI)
~duplError() throw()

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Synopsis

This template is for generalized duplicate key errors where the template type parameter is the type of the key which caused the error. Because this class is derived from DuplError , the user to catch all duplicate key errors with one catch statement.

Example

throw(duplError(4,"ANY STRING"));

To Do

Member Description

duplError(t oI, const Char *str,Category c=BOUNDARY)
duplError(t oI, const String &str,Category c=BOUNDARY)
duplError(t oI,Category c=BOUNDARY) : DuplError(c), oKey(oI)

This constructs a "duplError" for the offending key, and an optional character string.

~duplError() throw()

Destructor which does nothing.


class AbortError : public AipsError

Interface

AbortError(const Char *str,Category c=GENERAL)
AbortError(const String &str,Category c=GENERAL)
~AbortError() throw()

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Synopsis

This error causes an execution to halt regardless. It causes execution to halt before the exception can be caught.

Example

     throw(AbortError("ANY STRING"));

To Do

Member Description

AbortError(const Char *str,Category c=GENERAL)
AbortError(const String &str,Category c=GENERAL)

This constructs a "AbortError" from the error message.

~AbortError() throw()

Destructor which does nothing.