Open Inventor Reference
SoError Class Reference

Error handling base class. More...

#include <Inventor/errors/SoError.h>

Inheritance diagram for SoError:
SoDebugError SoMemoryError SoReadError

Public Member Functions

const SbStringgetDebugString () const
 Returns debug string containing full error information from instance.
 
virtual SoType getTypeId () const
 Returns type identifier for error instance.
 
bool isOfType (SoType type) const
 Returns TRUE if instance is of given type or is derived from it.
 

Static Public Member Functions

static void setHandlerCallback (SoErrorCB *cb, void *data)
 Sets/returns handler callback for SoError class.
 
static SoErrorCBgetHandlerCallback ()
 Sets/returns handler callback for SoError class.
 
static void * getHandlerData ()
 Sets/returns handler callback for SoError class.
 
static SoType getClassTypeId ()
 Returns type identifier for SoError class.
 
static void post (const char *formatString ...)
 Posts an error.
 
static SbString getString (const SoNode *node)
 These are convenience functions that return a printable string representing the given object.
 
static SbString getString (const SoPath *path)
 
static SbString getString (const SoEngine *engine)
 
static void initClass ()
 Initializes SoError class.
 
static void initClasses ()
 Initialize ALL Inventor error classes.
 

Protected Member Functions

virtual SoErrorCBgetHandler (void *&data) const
 Returns handler callback (and data) to use for a given instance.
 
void setDebugString (const char *string)
 Sets/appends to the debug string.
 
void appendToDebugString (const char *string)
 
void handleError ()
 Calls appropriate handler for an error instance.
 
virtual ~SoError ()
 

Static Protected Member Functions

static void defaultHandlerCB (const SoError *error, void *data)
 The default error handler callback - it just prints to stderr.
 

Detailed Description

SoError is the base class for all error classes, which provide error handling for applications. There are two facets to errors: posting and handling. An error is posted when some bad condition occurs. Posting is done primarily by the Inventor library itself, but extenders can post their own errors. Posting an error creates an instance of the appropriate error class (or subclass) and then passes it to the active error handler. The default handler just prints an appropriate message to stderr. Applications can override this behavior by supplying a different handler (by specifying a callback function).

Each subclass of SoError supports the setHandlerCallback() method, which is used to set the callback function to handle errors. The callback function for a specfic error class is always used in preference to that of any base classes when handling errors. The error instance passed to a callback is deleted immediately after the callback is called; an application that wishes to save information from the instance has to copy it out first.

Each error class contains a run-time class type id (SoType) that can be used to determine the type of an instance. The base class defines a character string that represents a detailed error message that is printed by the default handler. All handlers are called by the SoError::handleError() method. When debugging, you can set a breakpoint on this method to stop right before an error is handled.

See Also
SoDebugError, SoMemoryError, SoReadError

Definition at line 117 of file SoError.h.

Constructor & Destructor Documentation

◆ ~SoError()

virtual SoError::~SoError ( )
inlineprotectedvirtual

Definition at line 179 of file SoError.h.

Member Function Documentation

◆ appendToDebugString()

void SoError::appendToDebugString ( const char *  string)
inlineprotected

Definition at line 172 of file SoError.h.

◆ defaultHandlerCB()

static void SoError::defaultHandlerCB ( const SoError error,
void *  data 
)
staticprotected

◆ getClassTypeId()

static SoType SoError::getClassTypeId ( )
inlinestatic

Definition at line 133 of file SoError.h.

◆ getDebugString()

const SbString & SoError::getDebugString ( ) const
inline

Definition at line 130 of file SoError.h.

◆ getHandler()

virtual SoErrorCB * SoError::getHandler ( void *&  data) const
protectedvirtual

Reimplemented in SoDebugError, SoMemoryError, and SoReadError.

◆ getHandlerCallback()

static SoErrorCB * SoError::getHandlerCallback ( )
inlinestatic

Definition at line 125 of file SoError.h.

◆ getHandlerData()

static void * SoError::getHandlerData ( )
inlinestatic

Definition at line 127 of file SoError.h.

◆ getString() [1/3]

static SbString SoError::getString ( const SoEngine engine)
static

◆ getString() [2/3]

static SbString SoError::getString ( const SoNode node)
static

For example, a node is represented by name (if it has one) and by address; the returned string will be something like: node named "squid" at address 0x1004dcba

◆ getString() [3/3]

static SbString SoError::getString ( const SoPath path)
static

◆ getTypeId()

virtual SoType SoError::getTypeId ( ) const
virtual

Reimplemented in SoDebugError, SoMemoryError, and SoReadError.

◆ handleError()

void SoError::handleError ( )
protected

Application writers can set breakpoints at this when debugging.

◆ initClass()

static void SoError::initClass ( )
static

◆ initClasses()

static void SoError::initClasses ( )
static

◆ isOfType()

bool SoError::isOfType ( SoType  type) const

◆ post()

static void SoError::post ( const char *  formatString ...)
static

The debugString will be created from the given arguments, which are in printf() format

◆ setDebugString()

void SoError::setDebugString ( const char *  string)
inlineprotected

Definition at line 170 of file SoError.h.

◆ setHandlerCallback()

static void SoError::setHandlerCallback ( SoErrorCB cb,
void *  data 
)
inlinestatic

Definition at line 122 of file SoError.h.


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