libstorage-ng
Loading...
Searching...
No Matches
storage::Exception Class Reference

Base class for storage exceptions. More...

#include <Exception.h>

Inheritance diagram for storage::Exception:
[legend]
Collaboration diagram for storage::Exception:
[legend]

Public Member Functions

 Exception (LogLevel log_level=LogLevel::ERROR)
 Default constructor.
 Exception (const std::string &msg, LogLevel log_level=LogLevel::ERROR)
 Constructor taking a message.
virtual ~Exception () noexcept
 Destructor.
const CodeLocationwhere () const
 Return CodeLocation.
void relocate (const CodeLocation &newLocation) const
 Exchange location on rethrow.
const std::string & msg () const
 Return the message string provided to the constructor.
LogLevel log_level () const
void setMsg (const std::string &msg)
 Set a new message string.
std::string asString () const
 Error message provided by dumpOn as string.
virtual const char * what () const noexcept override
 Return message string.

Static Public Member Functions

static std::string strErrno (int errno_r)
 Make a string from errno_r.
static std::string strErrno (int errno_r, const std::string &msg)
 Make a string from errno_r and msg_r.
static void log (const Exception &exception, const CodeLocation &location, const char *const prefix)
 Drop a log line on throw, catch or rethrow.

Protected Member Functions

virtual std::ostream & dumpOn (std::ostream &str) const
 Overload this to print a proper error message.

Friends

std::ostream & operator<< (std::ostream &str, const Exception &obj)
 Exception stream output.

Detailed Description

Base class for storage exceptions.

Exception offers to store a message string passed to the constructor. Derived classes may provide additional information. Overload dumpOn to provide a proper error text.

Constructor & Destructor Documentation

◆ Exception() [1/2]

storage::Exception::Exception ( LogLevel log_level = LogLevel::ERROR)

Default constructor.

Use ST_THROW to throw exceptions.

◆ Exception() [2/2]

storage::Exception::Exception ( const std::string & msg,
LogLevel log_level = LogLevel::ERROR )

Constructor taking a message.

Use ST_THROW to throw exceptions.

Member Function Documentation

◆ dumpOn()

virtual std::ostream & storage::Exception::dumpOn ( std::ostream & str) const
protectedvirtual

Overload this to print a proper error message.

Reimplemented in storage::IndexOutOfRangeException, and storage::ParseException.

◆ log()

void storage::Exception::log ( const Exception & exception,
const CodeLocation & location,
const char *const prefix )
static

Drop a log line on throw, catch or rethrow.

Used by ST_THROW macros.

◆ msg()

const std::string & storage::Exception::msg ( ) const
inline

Return the message string provided to the constructor.

Note: This is not necessarily the complete error message. The whole error message is provided by asString or dumpOn.

◆ what()

virtual const char * storage::Exception::what ( ) const
inlineoverridevirtualnoexcept

Return message string.

Reimplemented from std::exception.


The documentation for this class was generated from the following file:
  • /home/abuild/rpmbuild/BUILD/libstorage-ng-4.5.260-build/libstorage-ng-4.5.260/storage/Utils/Exception.h