b2api
B2000++ API Reference Manual, VERSION 4.6
 
Loading...
Searching...
No Matches
b2000::Exception Class Reference

#include "b2exception.H"

Inheritance diagram for b2000::Exception:

Classes

struct  Throw
 
struct  Warning
 

Public Member Functions

 Exception (const std::string &msg_=std::string(), const char *file_=nullptr, int line_=-1)
 
const char * name () const noexcept
 
const char * get_file () const
 
int get_line () const
 
const std::string & get_msg () const
 
const std::string & get_backtrace (int start_level=1) const
 
template<typename T >
Exceptionoperator<< (const T &t)
 
template<typename T1 , typename T2 >
Exceptionoperator<< (const std::pair< T1, T2 > &t)
 
void operator<< (const Throw &t)
 
void operator<< (const Warning &w)
 

Detailed Description

Base class for exceptions. It supports composing of the error message like std::ostream, and it has support for backtraces, indicating the exact location in the source code where the exception was thrown.

Constructor & Destructor Documentation

◆ Exception()

b2000::Exception::Exception ( const std::string &  msg_ = std::string(),
const char *  file_ = nullptr,
int  line_ = -1 
)
inline

Create an exception instance.

Parameters
msg_The message, or the beginning of the message. Empty by default.
file_A pointer to a string containing the file name. 0 by default.
line_The line number. -1 by default.

Member Function Documentation

◆ get_backtrace()

const std::string & b2000::Exception::get_backtrace ( int  start_level = 1) const
Returns
The exception back trace as a string.

◆ get_file()

const char * b2000::Exception::get_file ( ) const
inline
Returns
The file name where the exception was thrown.

◆ get_line()

int b2000::Exception::get_line ( ) const
inline
Returns
The line number where the exception was thrown.

◆ get_msg()

const std::string & b2000::Exception::get_msg ( ) const
inline
Returns
The message associated with the exception.

◆ name()

const char * b2000::Exception::name ( ) const
inlinenoexcept
Returns
The name of the exception class.

◆ operator<<() [1/4]

template<typename T1 , typename T2 >
Exception & b2000::Exception::operator<< ( const std::pair< T1, T2 > &  t)
inline

Convert a std::pair to a string and append it to the message.

◆ operator<<() [2/4]

template<typename T >
Exception & b2000::Exception::operator<< ( const T &  t)
inline

Convert a value to a string and append it to the message.

◆ operator<<() [3/4]

void b2000::Exception::operator<< ( const Throw t)
inline

Set the location and immediately throw the Exception instance.

◆ operator<<() [4/4]

void b2000::Exception::operator<< ( const Warning w)
inline

Emit a warning message


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