h5cpp  0.5.2
A modern C++ wrapper for the HDF5 C library
hdf5::error::Singleton Class Reference

singleton class for HDF5 error handling More...

#include <error.hpp>

Public Member Functions

void auto_print (bool enable)
 toggle automatic printing of error stack More...
 
bool auto_print () const
 indicates if automatic printing of error stack is on More...
 
H5CError extract_stack ()
 returns most recent error stack as Stack More...
 
void throw_with_stack (const std::string &message)
 throws an exception, potentially nested with error stack More...
 
void clear_stack ()
 clears HDF5 error stack More...
 

Static Public Member Functions

static Singletoninstance ()
 reference to singleton More...
 

Detailed Description

This class facilitates handling of errors originating in the underlying C-API and HDF5 library. Singleton pattern assures a unique point of access to HDF5's active error stack.

Member Function Documentation

◆ auto_print() [1/2]

bool hdf5::error::Singleton::auto_print ( ) const

◆ auto_print() [2/2]

void hdf5::error::Singleton::auto_print ( bool  enable)

By default, HDF5 prints the error stack to sterr upon the occurrence of every error. Turning this off redirects the stack to be passed out to the client using nested exceptions.

Parameters
enableset to true if autoprinting should be enabled, false otherwise

◆ clear_stack()

void hdf5::error::Singleton::clear_stack ( )

◆ extract_stack()

H5CError hdf5::error::Singleton::extract_stack ( )

Only works if auto_print is disabled. Returns a Stack (derived exception) as extracted from the HDF5 error stack of the most recent error condition(s).

After the stack is extracted it will removed from the error system.

◆ instance()

static Singleton& hdf5::error::Singleton::instance ( )
inlinestatic

Use this static function to access the singleton

◆ throw_with_stack()

void hdf5::error::Singleton::throw_with_stack ( const std::string &  message)

If auto_print is enabled, throws std::runtime_error. If auto_print is disabled, it also extracts the error stack and throws a nested exception, with the Stack object one level deeper. This function is to be used by most other functions implementing this HDF5 wrapper.

Parameters
messagea user-supplied message for the exception

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