strusBase  0.17
Public Types | Public Member Functions | List of all members
strus::ErrorBufferInterface Class Referenceabstract

Interface for reporting and catching errors in modules. More...

#include <errorBufferInterface.hpp>

Inheritance diagram for strus::ErrorBufferInterface:
strus::LocalErrorBuffer

Public Types

enum  ErrorClass { None, RuntimeError, BadAlloc }
 

Public Member Functions

virtual ~ErrorBufferInterface ()
 Destructor. More...
 
virtual void setLogFile (FILE *hnd)=0
 Define error log file. More...
 
virtual bool setMaxNofThreads (unsigned int maxNofThreads)=0
 Redefine the maximum number of threads using the error buffer. More...
 
virtual void report (int errorcode, const char *format,...)=0
 Report an error. More...
 
virtual void explain (const char *format)=0
 Report an error, overwriting the previous error. More...
 
virtual const char * fetchError ()=0
 Check, if an error has occurred and return it. More...
 
virtual bool hasError () const =0
 Check, if an error has occurred. More...
 
virtual void allocContext ()=0
 Allocate context for current thread. More...
 
virtual void releaseContext ()=0
 Dellocate context for current thread. More...
 
virtual DebugTraceInterfacedebugTrace () const =0
 Fetches the debug trace interface if defined. More...
 

Detailed Description

Interface for reporting and catching errors in modules.

Note
C++ Coding Standards: 101 Rules, Guidelines, and Best Practices by Andrei Alexandrescu, Herb Sutter:
  1. Don’t allow exceptions to propagate across module boundaries

Member Enumeration Documentation

Enumerator
None 

no error

RuntimeError 

runtime error

BadAlloc 

memory allocation error

Constructor & Destructor Documentation

virtual strus::ErrorBufferInterface::~ErrorBufferInterface ( )
inlinevirtual

Destructor.

Member Function Documentation

virtual void strus::ErrorBufferInterface::allocContext ( )
pure virtual

Allocate context for current thread.

Remarks
allocContext & releaseContext have only to be called if assignement of thread ids is not fix

Implemented in strus::LocalErrorBuffer.

virtual DebugTraceInterface* strus::ErrorBufferInterface::debugTrace ( ) const
pure virtual

Fetches the debug trace interface if defined.

Returns
the debug trace interface if defined, NULL else

Implemented in strus::LocalErrorBuffer.

virtual void strus::ErrorBufferInterface::explain ( const char *  format)
pure virtual

Report an error, overwriting the previous error.

Parameters
[in]formaterror message format string
Remarks
must not throw

Implemented in strus::LocalErrorBuffer.

virtual const char* strus::ErrorBufferInterface::fetchError ( )
pure virtual

Check, if an error has occurred and return it.

Returns
an error string, if defined, NULL else
Remarks
resets the error

Implemented in strus::LocalErrorBuffer.

virtual bool strus::ErrorBufferInterface::hasError ( ) const
pure virtual

Check, if an error has occurred.

Returns
an error string, if defined, NULL else

Implemented in strus::LocalErrorBuffer.

virtual void strus::ErrorBufferInterface::releaseContext ( )
pure virtual

Dellocate context for current thread.

Remarks
allocContext & releaseContext have only to be called if assignement of thread ids is not fix

Implemented in strus::LocalErrorBuffer.

virtual void strus::ErrorBufferInterface::report ( int  errorcode,
const char *  format,
  ... 
)
pure virtual

Report an error.

Parameters
[in]errorcodeerror code of the error (errno and beyond)
Note
See include/strus/errorCodes.hpp
Parameters
[in]formaterror message format string
Remarks
must not throw

Implemented in strus::LocalErrorBuffer.

virtual void strus::ErrorBufferInterface::setLogFile ( FILE *  hnd)
pure virtual

Define error log file.

Parameters
[in]hndfile handle to set as log file
Remarks
not thread safe, assumed not to be called outside the main process initialization phase

Implemented in strus::LocalErrorBuffer.

virtual bool strus::ErrorBufferInterface::setMaxNofThreads ( unsigned int  maxNofThreads)
pure virtual

Redefine the maximum number of threads using the error buffer.

Parameters
[in]maxNofThreadsnumber of threads
Remarks
not thread safe, may invalidate all objects dependent on this, assumed not to be called outside the main process initialization phase

Implemented in strus::LocalErrorBuffer.


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