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

Object thrown when the program does something thought impossible. More...

#include <l_exception.h>

Inheritance diagram for kjb::Cant_happen:
kjb::Exception

Public Member Functions

 Cant_happen (const char *file, unsigned line)
 Ctor of Exception caused reaching presumably unreachable code. More...
 
 Cant_happen (const char *msg, const char *file=0, unsigned line=0)
 Ctor of Exception caused reaching presumably unreachable code. More...
 
 Cant_happen (const std::string &msg, const char *file=0, unsigned line=0)
 Ctor of Exception caused reaching presumably unreachable code. More...
 
virtual ~Cant_happen () throw ()
 Deletes a Cant_happen. More...
 
- Public Member Functions inherited from kjb::Exception
 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
 

Additional Inherited Members

- Protected Attributes inherited from kjb::Exception
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

Object thrown when the program does something thought impossible.

Throwing this object is appropriate when control reaches a lexical location of the source code that was thought to be unreachable. Alternatively, it might be helpful to think of throwing this when the program's internal state changes in a way thought to be impossible.

int rc = fclose( fp ); // as everyone knows, EOF if error, or 0 for success
if ( 0 == rc ) cout << "closed the file\n";
else if ( EOF == rc ) cerr << "cannot close the file\n";
else throw Cant_happen(__FILE__,__LINE__);

Constructor & Destructor Documentation

kjb::Cant_happen::Cant_happen ( const char *  file,
unsigned  line 
)

Ctor of Exception caused reaching presumably unreachable code.

Parameters
fileFile where the error occurred.
lineLine approximately where the error occurred.
kjb::Cant_happen::Cant_happen ( const char *  msg,
const char *  file = 0,
unsigned  line = 0 
)

Ctor of Exception caused reaching presumably unreachable code.

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

Ctor of Exception caused reaching presumably unreachable code.

Parameters
msgError message.
fileFile where the error occurred.
lineLine approximately where the error occurred.
virtual kjb::Cant_happen::~Cant_happen ( )
throw (
)
inlinevirtual

Deletes a Cant_happen.


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