casacore
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
casacore::AipsError Class Reference

More...

#include <Error.h>

Public Types

enum  Category {
  BOUNDARY ,
  INITIALIZATION ,
  INVALID_ARGUMENT ,
  CONFORMANCE ,
  ENVIRONMENT ,
  SYSTEM ,
  PERMISSION ,
  GENERAL
}
 

Public Member Functions

virtual const char * what () const noexcept
 Simply returns the stored error message. More...
 
const StringgetMesg () const
 
String getStackTrace () const
 
AipsError::Category getCategory () const
 
void setMessage (const String &msg) const
 Append a message. More...
 
 AipsError (const Char *str, Category c=GENERAL)
 Creates an AipsError and initializes the error message from the parameter. More...
 
 AipsError (const String &str, Category c=GENERAL)
 
 AipsError (const String &msg, const String &filename, uInt lineNumber, Category c=GENERAL)
 
 AipsError (Category c=GENERAL)
 
 ~AipsError () noexcept
 Destructor which does nothing. More...
 

Static Public Member Functions

static void getLastInfo (String &message, String &stackTrace)
 Get or clear the stacktrace info. More...
 
static String getLastMessage ()
 
static String getLastStackTrace ()
 
static void clearLastInfo ()
 
static AipsError repackageAipsError (AipsError &error, const String &message, const char *file, Int line, const char *func)
 Repackage an exception. More...
 
static void throwIf (Bool condition, const String &message, const char *file, Int line, const char *func="")
 Throw if the condition is true. More...
 
static void throwIfError (Int errorCode, const String &prefix, const char *file, Int line, const char *func="")
 Throw if the system error code is not 0. More...
 

Protected Member Functions

void addStackTrace ()
 Add the stack trace to the message (if USE_STACKTRACE is set). More...
 

Protected Attributes

String message
 
Category category
 
String stackTrace
 

Detailed Description

Base class for all Casacore library errors

Intended use:

Public interface

Review Status

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

Prerequisite

Synopsis

This is the base class for all of the Casacore 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"));
AipsError(const Char *str, Category c=GENERAL)
Creates an AipsError and initializes the error message from the parameter.

Definition at line 134 of file Error.h.

Member Enumeration Documentation

◆ Category

Enumerator
BOUNDARY 
INITIALIZATION 
INVALID_ARGUMENT 
CONFORMANCE 
ENVIRONMENT 
SYSTEM 
PERMISSION 
GENERAL 

Definition at line 138 of file Error.h.

Constructor & Destructor Documentation

◆ AipsError() [1/4]

casacore::AipsError::AipsError ( const Char str,
Category  c = GENERAL 
)

Creates an AipsError and initializes the error message from the parameter.

◆ AipsError() [2/4]

casacore::AipsError::AipsError ( const String str,
Category  c = GENERAL 
)

◆ AipsError() [3/4]

casacore::AipsError::AipsError ( const String msg,
const String filename,
uInt  lineNumber,
Category  c = GENERAL 
)

◆ AipsError() [4/4]

casacore::AipsError::AipsError ( Category  c = GENERAL)

◆ ~AipsError()

casacore::AipsError::~AipsError ( )
noexcept

Destructor which does nothing.

Member Function Documentation

◆ addStackTrace()

void casacore::AipsError::addStackTrace ( )
protected

Add the stack trace to the message (if USE_STACKTRACE is set).

◆ clearLastInfo()

static void casacore::AipsError::clearLastInfo ( )
static

◆ getCategory()

AipsError::Category casacore::AipsError::getCategory ( ) const
inline

Definition at line 151 of file Error.h.

References category.

◆ getLastInfo()

static void casacore::AipsError::getLastInfo ( String message,
String stackTrace 
)
static

Get or clear the stacktrace info.

◆ getLastMessage()

static String casacore::AipsError::getLastMessage ( )
static

◆ getLastStackTrace()

static String casacore::AipsError::getLastStackTrace ( )
static

◆ getMesg()

const String& casacore::AipsError::getMesg ( ) const
inline

Definition at line 148 of file Error.h.

References message.

Referenced by casacore::MSSelectionLogError::handleError().

◆ getStackTrace()

String casacore::AipsError::getStackTrace ( ) const

◆ repackageAipsError()

static AipsError casacore::AipsError::repackageAipsError ( AipsError error,
const String message,
const char *  file,
Int  line,
const char *  func 
)
static

Repackage an exception.

◆ setMessage()

void casacore::AipsError::setMessage ( const String msg) const
inline

Append a message.

This is used by LogIO when an exception is logged. The message is const to be able to use it for a temporary exception.

Definition at line 156 of file Error.h.

References message.

◆ throwIf()

static void casacore::AipsError::throwIf ( Bool  condition,
const String message,
const char *  file,
Int  line,
const char *  func = "" 
)
static

Throw if the condition is true.

◆ throwIfError()

static void casacore::AipsError::throwIfError ( Int  errorCode,
const String prefix,
const char *  file,
Int  line,
const char *  func = "" 
)
static

Throw if the system error code is not 0.

◆ what()

virtual const char* casacore::AipsError::what ( ) const
inlinevirtualnoexcept

Simply returns the stored error message.

Definition at line 146 of file Error.h.

References casacore::String::c_str(), and message.

Member Data Documentation

◆ category

Category casacore::AipsError::category
protected

Definition at line 204 of file Error.h.

Referenced by getCategory().

◆ message

String casacore::AipsError::message
protected

Definition at line 203 of file Error.h.

Referenced by getMesg(), casacore::MSSelectionError::reset(), setMessage(), and what().

◆ stackTrace

String casacore::AipsError::stackTrace
protected

Definition at line 205 of file Error.h.


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