KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Attributes | List of all members
kjb::Exception Class Reference

Base class of all exceptions in the jwsc++ library. More...

#include <l_exception.h>

Inheritance diagram for kjb::Exception:
kjb::Cant_happen kjb::IO_error kjb::KJB_error kjb::Missing_dependency kjb::Not_implemented kjb::Option_exception kjb::Result_error kjb::Runtime_error

Public Member Functions

 Exception (const char *msg, const char *file=0, unsigned line=0)
 Constructs an Exception. More...
 
 Exception (const std::string &msg, const char *file=0, unsigned line=0)
 Constructs an Exception. More...
 
 Exception (const Exception &e)
 Constructs an Exception from another. More...
 
virtual ~Exception () throw ()
 Deletes an Exception. More...
 
const std::string & get_msg () const throw ()
 Returns the error message for the Exception. More...
 
const char * what () const throw ()
 Returns the error message for the Exception. More...
 
const char * get_file () const
 Returns the file name where the Exception occurred. More...
 
unsigned get_line () const
 Returns the line number near where the Exception occurred. More...
 
std::string get_details () const
 Return string containing filename, line number, and message. More...
 
virtual void print (std::ostream &out, bool newline=false) const
 Prints the Exception::msg to an ostream. More...
 
virtual void print () const
 
virtual void print_details (std::ostream &out, bool newline=false) const
 Prints all the fields of the Exception to an ostream. More...
 
virtual void print_details () const
 
virtual void print_abort (std::ostream &out, bool newline=false) const
 Prints the Exception::msg to an ostream and aborts. More...
 
virtual void print_abort () const
 
virtual void print_details_abort (std::ostream &out, bool newline=false) const
 Prints all the fields of the Exception to an ostream and aborts. More...
 
virtual void print_details_abort () const
 
virtual void print_exit (std::ostream &out, bool newline, int status=false) const
 Prints the Exception::msg to an ostream and exits. More...
 
virtual void print_exit () const
 
virtual void print_details_exit (std::ostream &out, bool newline=false, int status=EXIT_FAILURE) const
 Prints all the fields of the Exception to an ostream and exits. More...
 
virtual void print_details_exit () const
 

Protected Attributes

std::string m_msg
 Message associated with the error causing the exception. More...
 
const char * m_file
 File name where the Error occurred. More...
 
unsigned m_line
 Line number where the Error occurred. More...
 

Detailed Description

Base class of all exceptions in the jwsc++ library.

Constructor & Destructor Documentation

kjb::Exception::Exception ( const char *  msg,
const char *  file = 0,
unsigned  line = 0 
)

Constructs an Exception.

Parameters
msgError message.
fileFile where the error occurred.
lineLine approximately where the error occurred.
kjb::Exception::Exception ( const std::string &  msg,
const char *  file = 0,
unsigned  line = 0 
)

Constructs an Exception.

Parameters
msgError message.
fileFile where the error occurred.
lineLine approximately where the error occurred.
kjb::Exception::Exception ( const Exception e)

Constructs an Exception from another.

Parameters
eException to copy into this one.
virtual kjb::Exception::~Exception ( )
throw (
)
inlinevirtual

Deletes an Exception.

Member Function Documentation

std::string kjb::Exception::get_details ( ) const

Return string containing filename, line number, and message.

const char* kjb::Exception::get_file ( ) const
inline

Returns the file name where the Exception occurred.

unsigned kjb::Exception::get_line ( ) const
inline

Returns the line number near where the Exception occurred.

const std::string& kjb::Exception::get_msg ( ) const
throw (
)
inline

Returns the error message for the Exception.

void kjb::Exception::print ( std::ostream &  out,
bool  newline = false 
) const
virtual

Prints the Exception::msg to an ostream.

Parameters
outOutput stream to print to.
newlineWhether to print a newline character.
void kjb::Exception::print ( ) const
virtual
void kjb::Exception::print_abort ( std::ostream &  out,
bool  newline = false 
) const
virtual

Prints the Exception::msg to an ostream and aborts.

Parameters
outOutput stream to print to.
newlineWhether to print a newline character.
void kjb::Exception::print_abort ( ) const
virtual
void kjb::Exception::print_details ( std::ostream &  out,
bool  newline = false 
) const
virtual

Prints all the fields of the Exception to an ostream.

Parameters
outOutput stream to print to.
newlineWhether to print a newline character.
void kjb::Exception::print_details ( ) const
virtual
void kjb::Exception::print_details_abort ( std::ostream &  out,
bool  newline = false 
) const
virtual

Prints all the fields of the Exception to an ostream and aborts.

print exception message to given stream, and then abort the program.

Parameters
outOutput stream to print to.
newlineWhether to print a newline character.
void kjb::Exception::print_details_abort ( ) const
virtual
void kjb::Exception::print_details_exit ( std::ostream &  out,
bool  newline = false,
int  status = EXIT_FAILURE 
) const
virtual

Prints all the fields of the Exception to an ostream and exits.

Parameters
outOutput stream to print to.
newlineWhether to print a newline character.
statusExit status.
void kjb::Exception::print_details_exit ( ) const
virtual
void kjb::Exception::print_exit ( std::ostream &  out,
bool  newline,
int  status = false 
) const
virtual

Prints the Exception::msg to an ostream and exits.

Parameters
outOutput stream to print to.
newlineWhether to print a newline character.
statusExit status.
void kjb::Exception::print_exit ( ) const
virtual
const char* kjb::Exception::what ( ) const
throw (
)
inline

Returns the error message for the Exception.

Member Data Documentation

const char* kjb::Exception::m_file
protected

File name where the Error occurred.

unsigned kjb::Exception::m_line
protected

Line number where the Error occurred.

std::string kjb::Exception::m_msg
protected

Message associated with the error causing the exception.


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