libthrowable::UserFault Class Reference
[Exception handling]

This class describes an Exception object directly aimed at the enduser. More...

#include <libthrowable/user_fault.h>

Inheritance diagram for libthrowable::UserFault:

Inheritance graph
[legend]
Collaboration diagram for libthrowable::UserFault:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 UserFault (const std::string &msg) throw ()
 Constructs a new UserFault from msg.
 UserFault (const char *filename, int linenumber, const std::string &msg) throw ()
 Constructs a new UserFault from filename, linenumber and msg.
 UserFault (const char *filename, int linenumber, const char *function, const std::string &msg) throw ()
 Constructs a new UserFault from filename, linenumber, function and msg.
 UserFault (const std::exception &cause, const std::string &msg) throw ()
 Constructs a new UserFault from cause.
virtual const std::string & getMessage () const throw ()
 Returns an error message targeted at the end user.
virtual ~UserFault () throw ()

Protected Member Functions

 UserFault (const std::string &msg, const std::string &passUnmodifiedToException) throw ()
 You may want to use this constructor when derivin classes from this one.
std::string & getInternalMessage () throw ()
 Gives you a refernce to the string that defines the return value of getMessage().


Detailed Description

This class describes an Exception object directly aimed at the enduser.

Note:
'an Exception object aimed directly at the enduser' should be considered as error message to be consumed by the user boxed in an Exception object. Imagine for example you write a calculator. When your (correctly working) parse method fails while parsing it's input, it is most likely, that the user, who indirectly supplied it with an invalid expression is responsible for this problem, so he/she is the one who should 'catch' your exception. Thus you will do something like
    if(parsing_failed)
        throw UserFault("not a valid expression: " + expr);
The client code of your calculator class may look like this:
    try
    {
        double result = calculator.parseExpr(expr);
            cout << "expr = " << result;
        }
        catch(const UserFault& fault)
        {
            cout << fault << endl;
        }

Constructor & Destructor Documentation

libthrowable::UserFault::UserFault ( const std::string &  msg  )  throw () [explicit]

Constructs a new UserFault from msg.

Parameters:
msg This should be an (possibly) translated error message for the user, not for you as programmer.

libthrowable::UserFault::UserFault ( const char *  filename,
int  linenumber,
const std::string &  msg 
) throw ()

Constructs a new UserFault from filename, linenumber and msg.

libthrowable::UserFault::UserFault ( const char *  filename,
int  linenumber,
const char *  function,
const std::string &  msg 
) throw ()

Constructs a new UserFault from filename, linenumber, function and msg.

libthrowable::UserFault::UserFault ( const std::exception &  cause,
const std::string &  msg 
) throw ()

Constructs a new UserFault from cause.

virtual libthrowable::UserFault::~UserFault (  )  throw () [virtual]

libthrowable::UserFault::UserFault ( const std::string &  msg,
const std::string &  passUnmodifiedToException 
) throw () [protected]

You may want to use this constructor when derivin classes from this one.

Parameters:
msg This string defines the return value of getMessage() as long as you don't overide this method.
passUnmodifiedToException This string defines the return value of what() as long as you don't override this method.


Member Function Documentation

virtual const std::string& libthrowable::UserFault::getMessage (  )  const throw () [virtual]

Returns an error message targeted at the end user.

std::string& libthrowable::UserFault::getInternalMessage (  )  throw () [protected]

Gives you a refernce to the string that defines the return value of getMessage().

Note:
You should rarely use this method.


The documentation for this class was generated from the following file:
Generated on Wed Jan 9 18:07:18 2008 for libthrowable by  doxygen 1.5.4  Hosted on  SourceForge.net Logo